From 182e8a888bb5b29888ed646d8f1e689953a1f055 Mon Sep 17 00:00:00 2001 From: Bruno Dias Date: Tue, 29 Aug 2023 10:00:01 -0300 Subject: [PATCH] free http get response after done with it. (#295) --- src/clib-search.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/clib-search.c b/src/clib-search.c index 6e0edf30..87d853f0 100644 --- a/src/clib-search.c +++ b/src/clib-search.c @@ -108,18 +108,16 @@ static char *wiki_html_cache() { debug(&debugger, "setting cache from %s", CLIB_WIKI_URL); http_get_response_t *res = http_get(CLIB_WIKI_URL); - if (!res->ok) - return NULL; - char *html = strdup(res->data); - if (NULL == html) - return NULL; + char *html = NULL; + + if (res->ok && (html = strdup(res->data)) != NULL) { + clib_cache_save_search(html); + debug(&debugger, "wrote cach"); + } + http_get_free(res); - if (NULL == html) - return html; - clib_cache_save_search(html); - debug(&debugger, "wrote cach"); return html; }