mirror of
https://github.com/openharmony/third_party_spirv-tools.git
synced 2026-07-15 13:45:35 -04: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:
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user