Fix reordering of cleanup fns in archiver.c
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 15s

This commit is contained in:
Stephen Seo 2024-10-04 17:35:12 +09:00
parent 8e620fb0e9
commit 302f7f804d

View file

@ -2062,6 +2062,11 @@ int simple_archiver_write_v1(FILE *out_f, SDArchiverState *state,
if (state->parsed->compressor && state->parsed->decompressor) { if (state->parsed->compressor && state->parsed->decompressor) {
// Is compressing. // Is compressing.
size_t temp_filename_size = strlen(state->parsed->temp_dir) + 1 + 64;
__attribute__((cleanup(
simple_archiver_helper_cleanup_c_string))) char *temp_filename =
malloc(temp_filename_size);
__attribute__((cleanup(cleanup_temp_filename_delete))) void **ptrs_array = __attribute__((cleanup(cleanup_temp_filename_delete))) void **ptrs_array =
malloc(sizeof(void *) * 2); malloc(sizeof(void *) * 2);
ptrs_array[0] = NULL; ptrs_array[0] = NULL;
@ -2070,11 +2075,6 @@ int simple_archiver_write_v1(FILE *out_f, SDArchiverState *state,
__attribute__((cleanup(simple_archiver_helper_cleanup_FILE))) __attribute__((cleanup(simple_archiver_helper_cleanup_FILE)))
FILE *temp_fd = NULL; FILE *temp_fd = NULL;
size_t temp_filename_size = strlen(state->parsed->temp_dir) + 1 + 64;
__attribute__((cleanup(
simple_archiver_helper_cleanup_c_string))) char *temp_filename =
malloc(temp_filename_size);
if (state->parsed->temp_dir) { if (state->parsed->temp_dir) {
size_t idx = 0; size_t idx = 0;
size_t temp_dir_len = strlen(state->parsed->temp_dir); size_t temp_dir_len = strlen(state->parsed->temp_dir);