sfeed_curses

[fork] sfeed (atom feed) reader
Log | Files | Refs | README | LICENSE

commit 50e5ea790350d784231d9b4a8332ee9b3cb39d6b
parent 98d9741bf02bf36770e921b424499bd6e7faf937
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Thu,  3 Sep 2020 22:32:38 +0200

improve memory and error handling of error-case in loading feed items

Reverts also part of the cleanup of the commit
d10b48c03250526ffd0df79ce1b74c943479c56b

This fixes a pattern which would've been a memory leak.  Note though that after
this function it would exit anyway and the memory would be free'd by the OS.

Diffstat:
Msfeed_curses.c | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -1077,6 +1077,7 @@ feed_items_get(struct feed *f, FILE *fp, struct items *itemsret) size_t cap, i, linesize = 0, nitems; ssize_t linelen; off_t offset; + int ret = -1; cap = nitems = 0; offset = 0; @@ -1115,17 +1116,18 @@ feed_items_get(struct feed *f, FILE *fp, struct items *itemsret) if (linelen <= 0 || feof(fp)) break; } - free(line); + ret = 0; + +err: itemsret->cap = cap; itemsret->items = items; itemsret->len = nitems; - return 0; - -err: free(line); - feed_items_free(itemsret); - return -1; + if (ret) + feed_items_free(itemsret); + + return ret; } void