diff options
author | Robert Guetzkow <gitcommit@outlook.de> | 2020-11-16 15:04:23 +0300 |
---|---|---|
committer | Robert Guetzkow <gitcommit@outlook.de> | 2020-11-16 15:17:24 +0300 |
commit | 8b815c7ce565b707fca9e9793bbec9784856f0f9 (patch) | |
tree | 6b315f40d0730b29eece38aabe2c1742e9532cad /source/blender | |
parent | 7db42b8f2a8cdec5067f2fe73082bd5d806a5e42 (diff) |
Fix T81271: Fix crash in BLI_gzopen on Windows
Previously the return value of `ufopen` wasn't checked and if it failed,
`NULL` was passed into `fclose()` which resulted in a crash. This patch
avoids this by returning from `BLI_gzopen` when the file cannot be created.
Reviewed By: sebbas, iss
Differential Revision: https://developer.blender.org/D9576
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 413c2007b1b..bb218995c83 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -357,7 +357,12 @@ void *BLI_gzopen(const char *filename, const char *mode) /* xxx Creates file before transcribing the path */ if (mode[0] == 'w') { - fclose(ufopen(filename, "a")); + FILE *file = ufopen(filename, "a"); + if (file == NULL) { + /* File couldn't be opened, e.g. due to permission error. */ + return NULL; + } + fclose(file); } /* temporary #if until we update all libraries to 1.2.7 |