From 503f147c564a70412fa1b2553ac43d8d0ab5b991 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Sun, 24 Apr 2022 16:09:31 -0400 Subject: [PATCH] wasi: remove unecessary null check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 PR-URL: https://github.com/nodejs/node/pull/42819 Reviewed-By: Luigi Pinca Reviewed-By: Tobias Nießen Reviewed-By: Darshan Sen --- src/node_wasi.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/node_wasi.cc b/src/node_wasi.cc index ffcc37c5274c98..803edf0c91dda1 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -236,11 +236,9 @@ void WASI::New(const FunctionCallbackInfo& args) { delete[] options.argv; } - if (options.envp != nullptr) { - for (uint32_t i = 0; options.envp[i]; i++) - free(const_cast(options.envp[i])); - delete[] options.envp; - } + for (uint32_t i = 0; options.envp[i]; i++) + free(const_cast(options.envp[i])); + delete[] options.envp; if (options.preopens != nullptr) { for (uint32_t i = 0; i < options.preopenc; i++) {