]> wimlib.net Git - wimlib/blobdiff - src/extract.c
create_temporary_file(): Fix use-after-free
[wimlib] / src / extract.c
index 5939671716455dc0c0a3b0008db82da450050e59..3438ca73327ba3f29684967a2ba91536027810d8 100644 (file)
@@ -1221,11 +1221,12 @@ retry:
        raw_fd = topen(name, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0600);
 
        if (raw_fd < 0) {
-               int errno_save = errno;
-               FREE(name);
-               if (errno_save == EEXIST)
+               if (errno == EEXIST) {
+                       FREE(name);
                        goto retry;
+               }
                ERROR_WITH_ERRNO("Failed to open temporary file \"%"TS"\"", name);
+               FREE(name);
                return WIMLIB_ERR_OPEN;
        }