Merge lp:~macslow/notify-osd/fix-425508 into lp:notify-osd/karmic

Proposed by Mirco Müller
Status: Merged
Merged at revision: not available
Proposed branch: lp:~macslow/notify-osd/fix-425508
Merge into: lp:notify-osd/karmic
Diff against target: 79 lines
1 file modified
src/bubble.c (+36/-23)
To merge this branch: bzr merge lp:~macslow/notify-osd/fix-425508
Reviewer Review Type Date Requested Status
David Barth (community) Approve
Review via email: mp+13472@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

Made bubble_append_message_body() avoid accidentally calling g_free() on an uninitialized pointer (text). pango_parse_markup() can leave text untouched, so later on g_free() would fail without initializing text to NULL correctly. Also made tests results more robust. This is meant to fix LP: #425508 and its duplicates...

LP: #426230
LP: #427129
LP: #429025

Revision history for this message
David Barth (dbarth) wrote :

Good catch!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/bubble.c'
2--- src/bubble.c 2009-10-15 13:33:14 +0000
3+++ src/bubble.c 2009-10-16 14:05:21 +0000
4@@ -3635,39 +3635,52 @@
5 bubble_append_message_body (Bubble* self,
6 const gchar* append_body)
7 {
8- gboolean result;
9- gchar* text;
10- GError* error = NULL;
11+ gboolean result = FALSE;
12+ gchar* text = NULL;
13+ GError* error = NULL;
14+ BubblePrivate* priv = NULL;
15
16- if (!self || !IS_BUBBLE (self))
17+ if (!self || !IS_BUBBLE (self) || !append_body)
18 return;
19
20- /* filter out any HTML/markup if possible */
21+ priv = GET_PRIVATE (self);
22+
23+ // filter out any HTML/markup if possible
24 result = pango_parse_markup (append_body,
25 -1,
26- 0, /* no accel-marker needed */
27- NULL, /* no PangoAttr needed */
28+ 0, // no accel-marker needed
29+ NULL, // no PangoAttr needed
30 &text,
31- NULL, /* no accel-marker-return needed */
32+ NULL, // no accel-marker-return needed
33 &error);
34- if (error)
35+ if (error && !result)
36 {
37- g_warning ("bubble_append_message_body(): Got error \"%s\"\n",
38- error->message);
39+ g_warning ("%s(): Got error \"%s\"\n",
40+ G_STRFUNC,
41+ error->message);
42 g_error_free (error);
43 error = NULL;
44- }
45-
46- /* append text to current message-body */
47- g_string_append (GET_PRIVATE (self)->message_body, text);
48-
49- g_signal_emit (self, g_bubble_signals[MESSAGE_BODY_INSERTED], 0, text);
50-
51- g_object_notify (
52- G_OBJECT (gtk_widget_get_accessible (GET_PRIVATE(self)->widget)),
53- "accessible-description");
54-
55- g_free ((gpointer) text);
56+
57+ if (text)
58+ g_free (text);
59+ }
60+
61+ if (text)
62+ {
63+ // append text to current message-body
64+ g_string_append (priv->message_body, text);
65+
66+ g_signal_emit (self,
67+ g_bubble_signals[MESSAGE_BODY_INSERTED],
68+ 0,
69+ text);
70+
71+ g_object_notify (
72+ G_OBJECT (gtk_widget_get_accessible (priv->widget)),
73+ "accessible-description");
74+
75+ g_free (text);
76+ }
77 }
78
79 void

Subscribers

People subscribed via source and target branches

to all changes: