]> git.seodisparate.com - SimpleArchiver/commitdiff
Sanity checks for handling temporary files cleanup
authorStephen Seo <seo.disparate@gmail.com>
Thu, 26 Dec 2024 01:46:32 +0000 (10:46 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Thu, 26 Dec 2024 01:46:32 +0000 (10:46 +0900)
src/archiver.c

index e0569d06b13333d3f042da00769ae8350e0b54aa..3a8775a5c537fc92d5b37e22afecfe829f39e04f 100644 (file)
@@ -2719,7 +2719,9 @@ int simple_archiver_write_v1(FILE *out_f, SDArchiverState *state,
           }
         } while (1);
         temp_fd = fopen(temp_filename, "w+b");
-        ptrs_array[0] = temp_filename;
+        if (temp_fd) {
+          ptrs_array[0] = temp_filename;
+        }
       } else {
         temp_fd = tmpfile();
       }
@@ -3599,7 +3601,9 @@ int simple_archiver_write_v2(FILE *out_f, SDArchiverState *state,
           }
         } while (1);
         temp_fd = fopen(temp_filename, "w+b");
-        ptrs_array[0] = temp_filename;
+        if (temp_fd) {
+          ptrs_array[0] = temp_filename;
+        }
       } else {
         temp_fd = tmpfile();
       }