aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <descalante@igalia.com>2010-12-07 19:39:39 +0800
committerDiego Escalante Urrelo <descalante@igalia.com>2010-12-07 19:40:23 +0800
commit7a0f902ad4ab5c34d70897ac3e6cec59baf690ff (patch)
tree596255d61a900c03bcfdad00f7deacc86360d05e /lib
parent4a8a0f51849d8414cadfdeb5527820c4a689343a (diff)
downloadgsoc2013-epiphany-7a0f902ad4ab5c34d70897ac3e6cec59baf690ff.tar.gz
gsoc2013-epiphany-7a0f902ad4ab5c34d70897ac3e6cec59baf690ff.tar.zst
gsoc2013-epiphany-7a0f902ad4ab5c34d70897ac3e6cec59baf690ff.zip
ephy-profile-utils: fix crasher when .migrated is unreadable
When .gnome2/epiphany/.migrated file is unreadable we can hit a crasher due to sscanf. We now check for NULL before feeding sscanf.
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-profile-utils.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/ephy-profile-utils.c b/lib/ephy-profile-utils.c
index 3f8e0922a..dfa6527be 100644
--- a/lib/ephy-profile-utils.c
+++ b/lib/ephy-profile-utils.c
@@ -31,9 +31,9 @@
int
ephy_profile_utils_get_migration_version ()
{
- char *migrated_file, *contents;
+ char *migrated_file, *contents = NULL;
gsize size;
- int result;
+ int result = 0;
int latest = 0;
migrated_file = g_build_filename (ephy_dot_dir (),
@@ -42,7 +42,9 @@ ephy_profile_utils_get_migration_version ()
if (g_file_test (migrated_file, G_FILE_TEST_EXISTS)) {
g_file_get_contents (migrated_file, &contents, &size, NULL);
- result = sscanf(contents, "%d", &latest);
+
+ if (contents != NULL)
+ result = sscanf(contents, "%d", &latest);
g_free (contents);
g_free (migrated_file);