mirror of
https://github.com/RPCSX/SPIRV-Tools.git
synced 2025-02-01 17:02:51 +00:00
fix SIGSEGV when reading from a non-existant file (#4453)
When a tool (tested with spirv-dis and spirv-as) runs on a file that does not exist, it notifies the user and tries to close the stream that was never successfully opened.
This commit is contained in:
parent
00b106e769
commit
881001070a
@ -89,7 +89,7 @@ bool ReadBinaryFile(const char* filename, std::vector<T>* data) {
|
||||
|
||||
ReadFile(fp, data);
|
||||
bool succeeded = WasFileCorrectlyRead<T>(fp, filename);
|
||||
if (use_file) fclose(fp);
|
||||
if (use_file && fp) fclose(fp);
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ bool ReadTextFile(const char* filename, std::vector<T>* data) {
|
||||
|
||||
ReadFile(fp, data);
|
||||
bool succeeded = WasFileCorrectlyRead<T>(fp, filename);
|
||||
if (use_file) fclose(fp);
|
||||
if (use_file && fp) fclose(fp);
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user