From 27f2b3bce139c9dd2816ae591f03ca34dd04705c Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Thu, 21 Apr 2022 17:15:02 -0400 Subject: [PATCH] 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 --- 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++) {