From: Stephen Seo Date: Thu, 26 Dec 2024 01:46:32 +0000 (+0900) Subject: Sanity checks for handling temporary files cleanup X-Git-Tag: 1.10^2~6 X-Git-Url: https://git.seodisparate.com/stephenseo/server_config?a=commitdiff_plain;h=b73140752e06baf3ccf971aef711bcd5d986ef46;p=SimpleArchiver Sanity checks for handling temporary files cleanup --- diff --git a/src/archiver.c b/src/archiver.c index e0569d0..3a8775a 100644 --- a/src/archiver.c +++ b/src/archiver.c @@ -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(); }