diff options
Diffstat (limited to 'linux-user/gen-vdso.c')
-rw-r--r-- | linux-user/gen-vdso.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/linux-user/gen-vdso.c b/linux-user/gen-vdso.c index 721f38d..fce9d5c 100644 --- a/linux-user/gen-vdso.c +++ b/linux-user/gen-vdso.c @@ -56,13 +56,14 @@ static unsigned rt_sigreturn_addr; int main(int argc, char **argv) { - FILE *inf, *outf; + FILE *inf = NULL, *outf = NULL; long total_len; const char *prefix = "vdso"; const char *inf_name; const char *outf_name = NULL; - unsigned char *buf; + unsigned char *buf = NULL; bool need_bswap; + int ret = EXIT_FAILURE; while (1) { int opt = getopt(argc, argv, "o:p:r:s:"); @@ -129,7 +130,6 @@ int main(int argc, char **argv) fprintf(stderr, "%s: incomplete read\n", inf_name); return EXIT_FAILURE; } - fclose(inf); /* * Identify which elf flavor we're processing. @@ -205,19 +205,24 @@ int main(int argc, char **argv) fprintf(outf, " .rt_sigreturn_ofs = 0x%x,\n", rt_sigreturn_addr); fprintf(outf, "};\n"); - /* - * Everything should have gone well. - */ - if (fclose(outf)) { - goto perror_outf; + ret = EXIT_SUCCESS; + + cleanup: + free(buf); + + if (outf && fclose(outf) != 0) { + ret = EXIT_FAILURE; + } + if (inf && fclose(inf) != 0) { + ret = EXIT_FAILURE; } - return EXIT_SUCCESS; + return ret; perror_inf: perror(inf_name); - return EXIT_FAILURE; + goto cleanup; perror_outf: perror(outf_name); - return EXIT_FAILURE; + goto cleanup; } |