]> wimlib.net Git - wimlib/commitdiff
create_temporary_file(): Fix use-after-free
authorEric Biggers <ebiggers3@gmail.com>
Sat, 21 Dec 2013 00:31:35 +0000 (18:31 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 21 Dec 2013 00:31:35 +0000 (18:31 -0600)
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) {
        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;
                        goto retry;
+               }
                ERROR_WITH_ERRNO("Failed to open temporary file \"%"TS"\"", name);
                ERROR_WITH_ERRNO("Failed to open temporary file \"%"TS"\"", name);
+               FREE(name);
                return WIMLIB_ERR_OPEN;
        }
 
                return WIMLIB_ERR_OPEN;
        }