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 authored and danielleadams committed Jun 27, 2022
1 parent 2747d9f commit 3d36622
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 3d36622

Please sign in to comment.