Merge lp:~mterry/libdbusmenu/sanitize-null-pointers into lp:libdbusmenu/0.5

Proposed by Michael Terry
Status: Merged
Approved by: Ted Gould
Approved revision: 269
Merged at revision: 270
Proposed branch: lp:~mterry/libdbusmenu/sanitize-null-pointers
Merge into: lp:libdbusmenu/0.5
Diff against target: 26 lines (+8/-2)
1 file modified
libdbusmenu-gtk/parser.c (+8/-2)
To merge this branch: bzr merge lp:~mterry/libdbusmenu/sanitize-null-pointers
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+53314@code.launchpad.net

Description of the change

Whoops, my version of sanitize_label_text didn't handle NULL well. pango_parse_markup returned FALSE in that case without setting the error pointer. Then my code assumed the error pointer was valid.

So I now check the error pointer as well as added an early exit for being passed a NULL in the first place.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Looks good.

  review approve
  merge approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-gtk/parser.c'
2--- libdbusmenu-gtk/parser.c 2011-03-09 22:52:46 +0000
3+++ libdbusmenu-gtk/parser.c 2011-03-14 20:06:40 +0000
4@@ -371,14 +371,20 @@
5 which we don't. */
6 gchar * sanitized = NULL;
7 GError * error = NULL;
8+
9+ if (label == NULL) {
10+ return NULL;
11+ }
12+
13 if (pango_parse_markup (label, -1, 0, NULL, &sanitized, NULL, &error)) {
14 return sanitized;
15 }
16- else {
17+
18+ if (error != NULL) {
19 g_warning ("Could not parse '%s': %s", label, error->message);
20 g_error_free (error);
21- return g_strdup (label);
22 }
23+ return g_strdup (label);
24 }
25
26 static gchar *

Subscribers

People subscribed via source and target branches