src: guard against env != null in node_errors.cc

Otherwise
`TriggerUncaughtException()`
→ `PrintException()`
→ `GetErrorSource()`
can crash.

PR-URL: https://github.com/nodejs/node/pull/36414
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Anna Henningsen authored and Michaël Zasso committed 2021-05-01 09:44:41 +02:00
1 parent 681d2a7176
commit 6df1132c85
1 file changed
+1 -1
+1 -1
View File
@@ -62,7 +62,7 @@ static std::string GetErrorSource(Isolate* isolate,
Environment* env = Environment::GetCurrent(isolate);
const bool has_source_map_url =
!message->GetScriptOrigin().SourceMapUrl().IsEmpty();
if (has_source_map_url && env->source_maps_enabled()) {
if (has_source_map_url && env != nullptr && env->source_maps_enabled()) {
return sourceline;
}