diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-29 13:22:22 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-11 15:51:10 -0400 |
| commit | 9300ecd1b163b0eb057a3b70dfbae713febd00d7 (patch) | |
| tree | 89fae49f5830d6bf9357967f0ec9a6eee1254158 /src | |
| parent | eb362846147bea33242c66972493a2fce8ba7053 (diff) | |
| download | stasis-9300ecd1b163b0eb057a3b70dfbae713febd00d7.tar.gz | |
xmkstemp: UB, close handles correctly
* free tempfile
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/core/utils.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/lib/core/utils.c b/src/lib/core/utils.c index 0ba5170..35310b4 100644 --- a/src/lib/core/utils.c +++ b/src/lib/core/utils.c @@ -525,23 +525,19 @@ char *xmkstemp(FILE **fp, const char *mode) { } *fp = fdopen(fd, mode); if (!*fp) { - // unable to open, die - if (fd > 0) - close(fd); - *fp = NULL; + close(fd); return NULL; } char *path = strdup(t_name); if (!path) { // strdup failed, die - if (*fp) { - // close the file handle - fclose(*fp); - *fp = NULL; - } - // fall through. path is NULL. + // close the file handle + fclose(*fp); + *fp = NULL; + return NULL; } + return path; } |
