[GTK] Segfaults in enchant_broker_free_dict()
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Apr 2018 07:11:04 +0000 (07:11 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Apr 2018 07:11:04 +0000 (07:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183738

Reviewed by Michael Catanzaro.

Check enchant_broker_request_dict() didn't return nullptr before adding it to the m_enchantDictionaries vector.

* platform/text/enchant/TextCheckerEnchant.cpp:
(WebCore::TextCheckerEnchant::updateSpellCheckingLanguages):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230197 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp

index ea954d4..7da2cd2 100644 (file)
@@ -1,5 +1,17 @@
 2018-04-03  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] Segfaults in enchant_broker_free_dict()
+        https://bugs.webkit.org/show_bug.cgi?id=183738
+
+        Reviewed by Michael Catanzaro.
+
+        Check enchant_broker_request_dict() didn't return nullptr before adding it to the m_enchantDictionaries vector.
+
+        * platform/text/enchant/TextCheckerEnchant.cpp:
+        (WebCore::TextCheckerEnchant::updateSpellCheckingLanguages):
+
+2018-04-03  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [GTK] NetworkProcess from WebKitGtk+ 2.19.9x SIGSEVs in NetworkStorageSession (secret search callback)
         https://bugs.webkit.org/show_bug.cgi?id=183346
 
index 2e7f6e9..c926c1f 100644 (file)
@@ -140,8 +140,8 @@ void TextCheckerEnchant::updateSpellCheckingLanguages(const Vector<String>& lang
         for (auto& language : languages) {
             CString currentLanguage = language.utf8();
             if (enchant_broker_dict_exists(m_broker, currentLanguage.data())) {
-                EnchantDict* dict = enchant_broker_request_dict(m_broker, currentLanguage.data());
-                spellDictionaries.append(dict);
+                if (auto* dict = enchant_broker_request_dict(m_broker, currentLanguage.data()))
+                    spellDictionaries.append(dict);
             }
         }
     } else {
@@ -149,15 +149,15 @@ void TextCheckerEnchant::updateSpellCheckingLanguages(const Vector<String>& lang
         CString utf8Language = defaultLanguage().utf8();
         const char* language = utf8Language.data();
         if (enchant_broker_dict_exists(m_broker, language)) {
-            EnchantDict* dict = enchant_broker_request_dict(m_broker, language);
-            spellDictionaries.append(dict);
+            if (auto* dict = enchant_broker_request_dict(m_broker, language))
+                spellDictionaries.append(dict);
         } else {
             // No dictionaries selected, we get the first one from the list.
             Vector<CString> allDictionaries;
             enchant_broker_list_dicts(m_broker, enchantDictDescribeCallback, &allDictionaries);
             if (!allDictionaries.isEmpty()) {
-                EnchantDict* dict = enchant_broker_request_dict(m_broker, allDictionaries.first().data());
-                spellDictionaries.append(dict);
+                if (auto* dict = enchant_broker_request_dict(m_broker, allDictionaries.first().data()))
+                    spellDictionaries.append(dict);
             }
         }
     }