diff options
author | Michael Catanzaro <mcatanzaro@gnome.org> | 2021-04-08 12:43:18 -0500 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@gnome.org> | 2021-04-29 15:46:19 +0000 |
commit | ef84eb50fc015e103ac0dae28c69c2548f771921 (patch) | |
tree | c7bcfa142fcab3b285bbdb2e1a1777a019f14fe0 | |
parent | 725471b502fdd48c516d654123718aba3e3220da (diff) | |
download | epiphany-ef84eb50fc015e103ac0dae28c69c2548f771921.tar.gz |
Fix crash when importing bookmarks from Firefox
The problem is the strings returned by get_firefox_profiles() are freed
with g_free(), which is correct, but we are actually returning pointers
into the middle of the allocated region, rather than pointers to the
start of the string. Truncating a string using pointer arithmetic is a
nice trick for unowned strings, but for owned strings it doesn't work.
https://bugzilla.redhat.com/show_bug.cgi?id=1946648
(cherry picked from commit 7e31b93d937625602e910d7397d00cc6082a37be)
-rw-r--r-- | src/window-commands.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/window-commands.c b/src/window-commands.c index fd4dafcfa..30dc01459 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -137,22 +137,24 @@ static gchar * get_path (GIOChannel *channel) { gchar *line; - gchar *path; + const gchar *path; + gchar *result; gsize length; do { g_io_channel_read_line (channel, &line, &length, NULL, NULL); if (g_str_has_prefix (line, "Path")) { - path = g_strdup (line); + path = line; /* Extract value (e.g. Path=Value\n -> Value) */ path = strchr (path, '='); path++; - path[strcspn (path, "\n")] = 0; + ((gchar *)path)[strcspn (path, "\n")] = '\0'; + result = g_strdup (path); g_free (line); - return path; + return result; } g_free (line); |