diff --git a/src/common/clib-package.c b/src/common/clib-package.c index 08701174..94e2e25d 100644 --- a/src/common/clib-package.c +++ b/src/common/clib-package.c @@ -391,6 +391,10 @@ static inline int install_packages(list_t *list, const char *dir, int verbose) { if (slug) free(slug); if (error) { + if (pkg) { + clib_package_free(pkg); + pkg = NULL; + } list_iterator_destroy(iterator); iterator = NULL; rc = -1; @@ -679,11 +683,13 @@ clib_package_new_from_slug_with_package_name(const char *slug, int verbose, #else res = http_get(json_url); #endif - json = res->data; - _debug("status: %d", res->status); if (!res || !res->ok) { + http_get_free(res); + res = NULL; goto download; } + json = res->data; + _debug("status: %d", res->status); log = "fetch"; } }