[epiphany] ephy-profile-utils: fix crasher when .migrated is unreadable
- From: Diego Escalante Urrelo <diegoe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] ephy-profile-utils: fix crasher when .migrated is unreadable
- Date: Tue, 7 Dec 2010 11:48:16 +0000 (UTC)
commit 7a0f902ad4ab5c34d70897ac3e6cec59baf690ff
Author: Diego Escalante Urrelo <descalante igalia com>
Date: Tue Dec 7 12:39:39 2010 +0100
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.
lib/ephy-profile-utils.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/lib/ephy-profile-utils.c b/lib/ephy-profile-utils.c
index 3f8e092..dfa6527 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]