diff options
author | Vincent Sanders <vince@kyllikki.org> | 2013-11-03 15:00:40 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2013-11-03 15:00:40 +0000 |
commit | 5c3daf901377d84c916f26c62d8eec41b573c0c3 (patch) | |
tree | 9fa6fd8d40b27dff46279fa16ac5469195897dd1 /gtk | |
parent | 401d1fd1a68fa802247da36b220985ccc58fad94 (diff) | |
download | netsurf-5c3daf901377d84c916f26c62d8eec41b573c0c3.tar.gz netsurf-5c3daf901377d84c916f26c62d8eec41b573c0c3.tar.bz2 |
fix memory leak in error path (coverity 1109889)
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/scaffolding.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index 3d86975cc..0589b1e0f 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -1854,7 +1854,6 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) g = malloc(sizeof(*g)); if (g == NULL) { - warn_user("NoMemory", 0); return NULL; } @@ -1883,7 +1882,6 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) g->search = malloc(sizeof(struct gtk_search)); if (g->search == NULL) { - warn_user("NoMemory", 0); free(g); return NULL; } @@ -1901,23 +1899,20 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) #undef GET_WIDGET + /* allocate buttons */ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { - g->buttons[i] = malloc(sizeof(struct nsgtk_button_connect)); + g->buttons[i] = calloc(1, sizeof(struct nsgtk_button_connect)); if (g->buttons[i] == NULL) { - warn_user("NoMemory", 0); + for (i-- ; i >= BACK_BUTTON; i--) { + free(g->buttons[i]); + } + free(g); return NULL; } - g->buttons[i]->button = NULL; g->buttons[i]->location = -1; g->buttons[i]->sensitivity = true; - g->buttons[i]->main = NULL; - g->buttons[i]->rclick = NULL; - g->buttons[i]->popup = NULL; - g->buttons[i]->mhandler = NULL; - g->buttons[i]->bhandler = NULL; - g->buttons[i]->dataplus = NULL; - g->buttons[i]->dataminus = NULL; } + /* here custom toolbutton adding code */ g->offset = 0; g->toolbarmem = 0; |