Skip to content

Commit

Permalink
Fixed some memory leaks.
Browse files Browse the repository at this point in the history
Called XFree() after XGetWindowProperty().
Called g_list_free() after gtk_container_get_children().
Do not call strdup for gtk_tree_store_set().
  • Loading branch information
fujiwarat committed Aug 29, 2014
1 parent 0bcaea6 commit 029416b
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 41 deletions.
12 changes: 12 additions & 0 deletions input-pad/geometry-gdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ xkb_get_group_layouts_from_key (InputPadGtkWindow *window,
Atom xkb_rules_name, type;
int format;
unsigned long l, nitems, bytes_after;
unsigned char *orig_prop;
unsigned char *prop = NULL;

xdisplay = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (GTK_WIDGET (window)));
Expand All @@ -1060,47 +1061,58 @@ xkb_get_group_layouts_from_key (InputPadGtkWindow *window,
g_warning ("Could not get X property");
return NULL;
}
orig_prop = prop;
if (nitems < 3) {
g_warning ("Could not get group layout from X property");
if (orig_prop != NULL)
XFree (orig_prop);
return NULL;
}
for (l = 0; l < 2; l++) {
prop += strlen ((const char *) prop) + 1;
}
if (prop == NULL || *prop == '\0') {
g_warning ("No layouts form X property");
if (orig_prop != NULL)
XFree (orig_prop);
return NULL;
}
if (get_key == XKB_GET_LAYOUTS_KEY) {
names = g_strsplit ((gchar *) prop, ",", -1);
debug_print_group_layout_list (names);
XFree (orig_prop);

return names;
}
prop += strlen ((const char *) prop) + 1;
if (prop == NULL) {
g_warning ("No variants form X property");
XFree (orig_prop);
return NULL;
}
if (get_key == XKB_GET_VARIANTS_KEY) {
names = g_strsplit ((gchar *) prop, ",", -1);
debug_print_group_layout_list (names);
XFree (orig_prop);

return names;
}
prop += strlen ((const char *) prop) + 1;
if (prop == NULL) {
g_warning ("No options form X property");
XFree (orig_prop);
return NULL;
}
if (get_key == XKB_GET_OPTIONS_KEY) {
names = g_strsplit ((gchar *) prop, ",", -1);
debug_print_group_layout_list (names);
XFree (orig_prop);

return names;
}

g_assert_not_reached ();
XFree (orig_prop);
return NULL;
}

Expand Down
Loading

0 comments on commit 029416b

Please sign in to comment.