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 5939671..3438ca7 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;
        }