diff options
author | Lubomír Sedlář <lubomir.sedlar@gmail.com> | 2012-05-14 21:08:36 +0800 |
---|---|---|
committer | Claudio Saavedra <csaavedra@igalia.com> | 2012-05-21 18:02:24 +0800 |
commit | c60cec78bfb5622e0c5b472078f5952606a0cee4 (patch) | |
tree | 62b8855a0a39517f81b6c07c16b2fe3f339dd489 | |
parent | deb8f250c145e4cdc52a4618c2a15dfcd6276e5d (diff) | |
download | gsoc2013-epiphany-c60cec78bfb5622e0c5b472078f5952606a0cee4.tar.gz gsoc2013-epiphany-c60cec78bfb5622e0c5b472078f5952606a0cee4.tar.zst gsoc2013-epiphany-c60cec78bfb5622e0c5b472078f5952606a0cee4.zip |
Always close bookmarks file
During error handling it was possible to return from function without
closing bookmarks file and freeing two string, causing memory and
descriptor leaks.
https://bugzilla.gnome.org/show_bug.cgi?id=675888
-rw-r--r-- | src/bookmarks/ephy-bookmarks-import.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c index f6ed781cb..5d83f5538 100644 --- a/src/bookmarks/ephy-bookmarks-import.c +++ b/src/bookmarks/ephy-bookmarks-import.c @@ -712,20 +712,20 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks, GString *name, *url; char *parsedname; GList *folders = NULL; + gboolean retval = TRUE; if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN, EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING)) return FALSE; - name = g_string_new (NULL); - url = g_string_new (NULL); - - if (!(bf = fopen (filename, "r"))) { g_warning ("Failed to open file: %s\n", filename); return FALSE; } + name = g_string_new (NULL); + url = g_string_new (NULL); + while (!feof (bf)) { EphyNode *node; NSItemType t; @@ -753,10 +753,13 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks, if (node == NULL) { node = ephy_bookmarks_find_bookmark (bookmarks, url->str); + if (node == NULL) { + g_warning ("%s: `node' is NULL", G_STRFUNC); + retval = FALSE; + goto out; + } } - g_return_val_if_fail (node != NULL, FALSE); - if (folders != NULL) { EphyNode *keyword; @@ -781,11 +784,12 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks, break; } } +out: fclose (bf); g_string_free (name, TRUE); g_string_free (url, TRUE); - return TRUE; + return retval; } gboolean |