From: Eric Biggers Date: Sat, 21 Dec 2013 00:31:35 +0000 (-0600) Subject: create_temporary_file(): Fix use-after-free X-Git-Tag: v1.6.0~131 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=bbedc3e1934278c2ff2746b25b688477cffc9d83;hp=c86ed31aa6d3fb28cfa017fb8f6e4888a9ae26b2 create_temporary_file(): Fix use-after-free --- diff --git a/src/extract.c b/src/extract.c index 59396717..3438ca73 100644 --- a/src/extract.c +++ b/src/extract.c @@ -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; }