From 0f9f29019e1f42882096f649627be3c6e184f7da Mon Sep 17 00:00:00 2001 From: forever2k38 Date: Mon, 7 Sep 2026 16:54:12 +0200 Subject: fix: (most) memory leaks --- src/package.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/package.c') diff --git a/src/package.c b/src/package.c index ad7e4d0..6aeee65 100644 --- a/src/package.c +++ b/src/package.c @@ -139,12 +139,19 @@ int extract_package_info(lua_State *L, pow_package *pkg) { const char *hash = strdup(lua_tostring(L, -1)); + if (!hash) { + free(in); + free(out); + + printf("failed to strdup hash\n"); + + return 1; + } + src->hash = hash; pkg->source_count++; - printf("attempting to malloc\n"); - pkg->sources = realloc(pkg->sources, pkg->source_count * sizeof(pow_package_source *)); @@ -246,5 +253,11 @@ int pow_package_close(pow_package *pkg) { lua_close(pkg->L); + for (size_t i = 0; i > pkg->source_count; i++) { + pow_source_close(pkg->sources[i]); + } + + free(pkg); + return 0; } -- cgit v1.3