[evolution-data-server] libecal: Refactor system timezone key file parsing code



commit f851d77bcec88d4a2e664185ba760f9cfd08ee1f
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Fri Nov 29 08:51:11 2013 +0000

    libecal: Refactor system timezone key file parsing code
    
    Previously, the code could call g_strstrip(NULL) if a line started with
    a quotation mark but didn’t end with one, e.g.:
        MyKey="some-unbalanced-value
    
    The code now ignores unbalanced quotation marks, returning the odd one
    in the value rather than crashing (or stripping it).
    
    Found by scan-build.
    
    https://bugzilla.gnome.org/719533

 calendar/libecal/e-cal-system-timezone.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)
---
diff --git a/calendar/libecal/e-cal-system-timezone.c b/calendar/libecal/e-cal-system-timezone.c
index 8015428..78767ca 100644
--- a/calendar/libecal/e-cal-system-timezone.c
+++ b/calendar/libecal/e-cal-system-timezone.c
@@ -140,21 +140,13 @@ system_timezone_read_key_file (const gchar *filename,
 
                        len = strlen (value);
 
-                       if (value[0] == '\"') {
-                               if (value[len - 1] == '\"') {
-                                       if (retval)
-                                               g_free (retval);
-
-                                       retval = g_strndup (
-                                               value + 1, len - 2);
-                               }
-                       } else {
-                               if (retval)
-                                       g_free (retval);
-
-                               retval = g_strdup (line + strlen (key_eq));
+                       if (value[0] == '\"' && value[len - 1] == '\"') {
+                               value += 1;
+                               len -= 2;
                        }
 
+                       g_free (retval);
+                       retval = g_strndup (value, len);
                        g_strstrip (retval);
                }
 


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