sardemff7 / purple-events

libpurple events handling plugin and library
GNU General Public License v3.0
13 stars 3 forks source link

pidgin-2.10.6 crashes when receiving a displaying-emails-notification event with NULL parameters #3

Closed richardgv closed 12 years ago

richardgv commented 12 years ago

Environment: Gentoo ~amd64, pidgin-2.10.6, purple-events-9999

Problem:

Pidgin sometimes crash with SEGSEGV. Analyzing with gdb reveals purple_events_callback_emails_notification() is called with count = 1, but subject, from, to, and url are all NULL pointers. A bug inside Pidgin itself?

My workaround:

--- src/plugin/callbacks.old.c  2012-08-27 09:30:26.480006829 +0800
+++ src/plugin/callbacks.c      2012-08-27 09:31:41.040007073 +0800
@@ -407,6 +407,9 @@
     if ( ! purple_prefs_get_bool("/plugins/core/events/restrictions/stack-emails") )
         count = 1;

+    if (!subject || !from || !to || !url)
+        return;
+
     PurpleEventsHandler *handler;
     GList *handler_;
     guint i;

Update: Oops, didn't realize there's a place in the function that unconditionally sets count to 1. Silly me.

src/plugin/callbacks.c, line 407:

     if ( ! purple_prefs_get_bool("/plugins/core/events/restrictions/stack-emails") )
         count = 1;

This might be the cause. It should check if count is 0 before setting it to 1 unconditionally. Couldn't reproduce the issue now so no way to test, though.

Update #2: Correct fix should be:

--- src/plugin/callbacks.old.c  2012-08-27 21:29:22.978508096 +0800
+++ src/plugin/callbacks.c      2012-08-27 21:30:02.178508167 +0800
@@ -404,7 +404,7 @@
     if ( ! purple_prefs_get_bool("/plugins/core/events/events/emails") )
         return;

-    if ( ! purple_prefs_get_bool("/plugins/core/events/restrictions/stack-emails") )
+    if ( count && ! purple_prefs_get_bool("/plugins/core/events/restrictions/stack-emails") )
         count = 1;

     PurpleEventsHandler *handler;
sardemff7 commented 12 years ago

Thanks for reporting!

Fixed in c38c0afeb813fe695125eda52cc62829fbe08733