Skip to content

Commit 626fcb2

Browse files
mhdawsonjuanarbol
authored andcommitted
wasi: remove unecessary null check
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>
1 parent ff9b688 commit 626fcb2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/node_wasi.cc

+3-5
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,9 @@ void WASI::New(const FunctionCallbackInfo<Value>& args) {
236236
delete[] options.argv;
237237
}
238238

239-
if (options.envp != nullptr) {
240-
for (uint32_t i = 0; options.envp[i]; i++)
241-
free(const_cast<char*>(options.envp[i]));
242-
delete[] options.envp;
243-
}
239+
for (uint32_t i = 0; options.envp[i]; i++)
240+
free(const_cast<char*>(options.envp[i]));
241+
delete[] options.envp;
244242

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

0 commit comments

Comments
 (0)