Skip to content

Commit 7cd2913

Browse files
committed
Fix null pointer dereference in DependencyInfoDumpingHandler
Add a null check for the return value of GetOutputStream() in dependency_info.cc before dereferencing the stream pointer. When GetOutputStream() fails to open the output file (e.g., due to permission errors, full disk, or non-existent directory), it returns nullptr. The code previously unconditionally dereferenced this pointer, causing a segmentation fault (SIGSEGV). This is the same vulnerability pattern that was fixed in file_compiler.cc (commit 1d97901), but was missed in the dependency_info.cc code path. The fix follows the identical pattern: check the pointer for null before use and return false on failure. Bug: Null pointer dereference when glslc is invoked with -MD flag and the dependency info output file cannot be opened for writing.
1 parent 42c364e commit 7cd2913

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

glslc/src/dependency_info.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ bool DependencyInfoDumpingHandler::DumpDependencyInfo(
5050
std::ofstream potential_file_stream_for_dep_info_dump;
5151
std::ostream* dep_file_stream = shaderc_util::GetOutputStream(
5252
dep_file_name, &potential_file_stream_for_dep_info_dump, &std::cerr);
53+
if (!dep_file_stream) {
54+
// An error message has already been emitted to the stderr stream.
55+
return false;
56+
}
5357
*dep_file_stream << dep_string_stream.str();
5458
if (dep_file_stream->fail()) {
5559
std::cerr << "glslc: error: error writing dependent_files info to output "

0 commit comments

Comments
 (0)