Skip to content

Commit

Permalink
wasi: remove unecessary null check
Browse files Browse the repository at this point in the history
As reported by coverity the null check is
done after earlier code has already derefenced
options.envp. Either we should null check earlier
uses or this check is not necessary. Since options.envp
is created with new which should throw an
exception intead of returning null, it should
be safe to assume the null check is not required.

Signed-off-by: Michael Dawson <[email protected]>

PR-URL: nodejs/node#42819
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
  • Loading branch information
mhdawson authored and guangwong committed Oct 10, 2022
1 parent 76c55ec commit 687bd92
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/node_wasi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ void WASI::New(const FunctionCallbackInfo<Value>& args) {
delete[] options.argv;
}

if (options.envp != nullptr) {
for (uint32_t i = 0; options.envp[i]; i++)
free(const_cast<char*>(options.envp[i]));
delete[] options.envp;
}
for (uint32_t i = 0; options.envp[i]; i++)
free(const_cast<char*>(options.envp[i]));
delete[] options.envp;

if (options.preopens != nullptr) {
for (uint32_t i = 0; i < options.preopenc; i++) {
Expand Down

0 comments on commit 687bd92

Please sign in to comment.