diff options
Diffstat (limited to 'libasm/asm_end.c')
-rw-r--r-- | libasm/asm_end.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libasm/asm_end.c b/libasm/asm_end.c index 7fabe94d..7891fbb5 100644 --- a/libasm/asm_end.c +++ b/libasm/asm_end.c @@ -521,16 +521,23 @@ asm_end (AsmCtx_t *ctx) } #endif + char *tmp_fname = strdup (ctx->tmp_fname); + char *fname = strdup (ctx->fname); + + /* Free the resources. */ + __libasm_finictx (ctx); + /* Rename output file. */ - if (rename (ctx->tmp_fname, ctx->fname) != 0) + result = rename (tmp_fname, fname); + free (tmp_fname); + free (fname); + + if (result != 0) { __libasm_seterrno (ASM_E_CANNOT_RENAME); return -1; } - /* Free the resources. */ - __libasm_finictx (ctx); - return 0; } |