From: Dale Weiler Date: Fri, 8 Feb 2013 16:39:14 +0000 (+0000) Subject: Fix some memleaks. X-Git-Tag: before-library~126 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=533b2144c554179ba1375e3e49bee6a18715977f;p=xonotic%2Fgmqcc.git Fix some memleaks. --- diff --git a/pak.c b/pak.c index 1f905fe..494ad7f 100644 --- a/pak.c +++ b/pak.c @@ -530,37 +530,41 @@ int main(int argc, char **argv) { if (!file) { con_err("-file must be specified for output/input PAK file\n"); + vec_free(files); return EXIT_FAILURE; } if (extract) { if (!(pak = pak_open(file, "r"))) { con_err("failed to open PAK file %s\n", file); + vec_free(files); return EXIT_FAILURE; } if (!pak_extract_all(pak, (directory) ? directory : "./")) { con_err("failed to extract PAK %s (files may be missing)\n", file); pak_close(pak); + vec_free(files); return EXIT_FAILURE; } /* not possible */ - if (!pak_close(pak)) - abort(); - + pak_close(pak); + vec_free(files); util_meminfo(); return EXIT_SUCCESS; } if (!(pak = pak_open(file, "w"))) { con_err("failed to open PAK %s for writing\n", file); + vec_free(files); return EXIT_FAILURE; } if (directory && !fs_dir_change(directory)) { con_err("failed to change directory %s\n", directory); pak_close(pak); + vec_free(files); return EXIT_FAILURE; } @@ -568,13 +572,16 @@ int main(int argc, char **argv) { if (!(pak_insert_one(pak, files[iter]))) { con_err("failed inserting %s for PAK %s\n", files[iter], file); pak_close(pak); + vec_free(files); return EXIT_FAILURE; } } /* not possible */ - if (!pak_close(pak)) - abort(); + pak_close(pak); + vec_free(files); + + util_meminfo(); return EXIT_SUCCESS; }