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 <mdawson@devrus.com>

PR-URL: #42819
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
mhdawson committed Apr 24, 2022
1 parent 8f580c4 commit 503f147
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/node_wasi.cc
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 503f147

Please sign in to comment.