From 3120f496f7bca284535f0213bdbc4c72754f0867 Mon Sep 17 00:00:00 2001 From: David Crosby Date: Thu, 9 Jul 2015 20:34:04 -0600 Subject: Fix resource leak and a null return value dereference --- w3mbookmark.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'w3mbookmark.c') diff --git a/w3mbookmark.c b/w3mbookmark.c index fcbad11..4ffc630 100644 --- a/w3mbookmark.c +++ b/w3mbookmark.c @@ -81,6 +81,7 @@ print_bookmark_panel(char *bmark, char *url, char *title, char *charset) printf("\n"); } printf(bkmark_src2, html_quote(url), html_quote(title)); + fclose(f); } /* create new bookmark */ @@ -168,7 +169,10 @@ insert_bookmark(char *bmark, struct parsed_tagarg *data) /* In this case, a new bookmark is appeneded after the bookmark file */ return create_new_bookmark(bmark, section, title, url, "a"); } - f = fopen(bmark, "w"); + if ((f = fopen(bmark, "w")) == NULL) { + printf("\nCannot open bookmark %s\n", bmark); + return FALSE; + } while (tl->nitem) { fputs(popText(tl), f); } -- cgit v1.2.3