diff options
author | David Crosby <dave@dafyddcrosby.com> | 2015-07-10 02:34:04 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2015-08-11 12:59:27 +0000 |
commit | 3120f496f7bca284535f0213bdbc4c72754f0867 (patch) | |
tree | 2a7e84d5ab6aa3a8f70ffc22bf9508e07ffe164f | |
parent | Fix a divide-by-zero (diff) | |
download | w3m-3120f496f7bca284535f0213bdbc4c72754f0867.tar.gz w3m-3120f496f7bca284535f0213bdbc4c72754f0867.zip |
Fix resource leak and a null return value dereference
-rw-r--r-- | w3mbookmark.c | 6 |
1 files changed, 5 insertions, 1 deletions
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("</select>\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); } |