libedata-cal: Fix a potential g_strstrip(NULL) call
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Fri, 29 Nov 2013 08:56:57 +0000 (08:56 +0000)
committerMatthew Barnes <mbarnes@redhat.com>
Tue, 3 Dec 2013 21:37:25 +0000 (16:37 -0500)
If the calendar contained any attendees _not_ prefixed with ‘mailto:’,
the text variable would be NULL, and would cause an assertion failure in
g_strstrip().

Found by scan-build.

https://bugzilla.gnome.org/719533

calendar/libedata-cal/e-cal-backend-util.c

index 2c7cd23..ebdd1ed 100644 (file)
@@ -167,7 +167,7 @@ is_attendee_declined (icalcomponent *icalcomp,
             prop != NULL;
             prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) {
                gchar *attendee;
-               gchar *text = NULL;
+               gchar *text;
 
                attendee = icalproperty_get_value_as_string_r (prop);
                if (!attendee)
@@ -175,6 +175,9 @@ is_attendee_declined (icalcomponent *icalcomp,
 
                if (!g_ascii_strncasecmp (attendee, "mailto:", 7))
                        text = g_strdup (attendee + 7);
+               else
+                       text = g_strdup (attendee);
+
                text = g_strstrip (text);
 
                if (!g_ascii_strcasecmp (email, text)) {