]> git.seodisparate.com - SimpleArchiver/commitdiff
Reorder cleanup to proper location
authorStephen Seo <seo.disparate@gmail.com>
Fri, 4 Oct 2024 08:32:14 +0000 (17:32 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 4 Oct 2024 08:32:14 +0000 (17:32 +0900)
src/archiver.c

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