report: fix recent coverity warning

Fix warning about dereferencing null env

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/48954
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Michael Dawson authored and Ulises Gascón committed 2023-09-10 18:07:28 +00:00
1 parent f637fd46ab
commit 173aed4757
1 file changed
+7 -3
+7 -3
View File
@@ -857,9 +857,13 @@ std::string TriggerNodeReport(Isolate* isolate,
// Determine the required report filename. In order of priority:
// 1) supplied on API 2) configured on startup 3) default generated
if (!name.empty()) {
THROW_IF_INSUFFICIENT_PERMISSIONS(
env, permission::PermissionScope::kFileSystemWrite, name, name);
// Filename was specified as API parameter.
// we may not always be in a great state when generating a node report
// allow for the case where we don't have an env
if (env != nullptr) {
THROW_IF_INSUFFICIENT_PERMISSIONS(
env, permission::PermissionScope::kFileSystemWrite, name, name);
// Filename was specified as API parameter.
}
filename = name;
} else {
std::string report_filename;