cgmnlm

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/cgmnlm.git
Log | Files | Refs | README | LICENSE

commit 59d19b9894083cecafc4439f7df1031bd6cefb01
parent f80e4037c21c87b11b7b4bfefba5d33a0fcc1ea6
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Thu, 24 Sep 2020 11:35:15 -0400

Fix bookmark save/open

Fix a segfault on bookmark save and a memory leak on bookmark open.

Diffstat:
Msrc/gmnlm.c | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/gmnlm.c b/src/gmnlm.c @@ -157,7 +157,7 @@ save_bookmark(struct browser *browser) char *title = browser->page_title; if (title) { - title = trim_ws(strdup(browser->page_title)); + title = trim_ws(browser->page_title); } fprintf(f, "=> %s%s%s\n", browser->plain_url, @@ -166,17 +166,15 @@ save_bookmark(struct browser *browser) fprintf(browser->tty, "Bookmark saved: %s\n", title ? title : browser->plain_url); - if (title != NULL) { - free(title); - } } static void open_bookmarks(struct browser *browser) { - const char *path_fmt = get_data_pathfmt(); + char *path_fmt = get_data_pathfmt(); static char path[PATH_MAX+1]; snprintf(path, sizeof(path), path_fmt, "bookmarks.gmi"); + free(path_fmt); static char url[PATH_MAX+1+7]; snprintf(url, sizeof(url), "file://%s", path); set_url(browser, url, &browser->history);