[geary/wip/225-gmime-charset-crash] Fix crash in Geary.RFC822.init()



commit e06ec5e73e527983bcfb63ec707ed5b1d11ddde8
Author: Michael Gratton <mike vee net>
Date:   Thu Feb 21 11:06:05 2019 +1100

    Fix crash in Geary.RFC822.init()
    
    Due to an undocumented expectation in GMime.set_user_charsets(), the
    array passed in must be null-terminated.
    
    Fixes #225

 src/engine/rfc822/rfc822.vala | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822.vala b/src/engine/rfc822/rfc822.vala
index 49b9e05d..1c05dc9f 100644
--- a/src/engine/rfc822/rfc822.vala
+++ b/src/engine/rfc822/rfc822.vala
@@ -19,11 +19,6 @@ public enum TextFormat {
  */
 public const string UTF8_CHARSET = "UTF-8";
 
-// This has the effect of ensuring all non US-ASCII and non-ISO-8859-1
-// headers are always encoded as UTF-8. This should be fine because
-// message bodies are also always sent as UTF-8.
-private const string[] USER_CHARSETS =  { UTF8_CHARSET };
-
 private int init_count = 0;
 
 internal Regex? invalid_filename_character_re = null;
@@ -33,6 +28,16 @@ public void init() {
         return;
 
     GMime.init(GMime.ENABLE_RFC2047_WORKAROUNDS);
+
+    // This has the effect of ensuring all non US-ASCII and non-ISO-8859-1
+    // headers are always encoded as UTF-8. This should be fine because
+    // message bodies are also always sent as UTF-8.
+    const string?[] USER_CHARSETS =  {
+        UTF8_CHARSET,
+        // GMime.set_user_charsets calls g_strdupv under the hood, so
+        // the array needs to be null-terminated
+        null
+    };
     GMime.set_user_charsets(USER_CHARSETS);
 
     try {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]