wasi: remove unecessary null check#42819
Merged
nodejs-github-bot merged 1 commit intonodejs:masterfrom Apr 24, 2022
Merged
Conversation
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 <[email protected]>
Collaborator
|
Review requested:
|
Member
Author
|
From coverity Local<Array> env_pairs = args[1].As<Array>();
201 const uint32_t envc = env_pairs->Length();
202 options.envp = const_cast<const char**>(new char*[envc + 1]);
203 for (uint32_t i = 0; i < envc; i++) {
204 auto pair = env_pairs->Get(context, i).ToLocalChecked();
205 CHECK(pair->IsString());
206 node::Utf8Value str(env->isolate(), pair);
deref_ptr: Directly dereferencing pointer options.envp.
207 options.envp[i] = strdup(*str);
208 CHECK_NOT_NULL(options.envp[i]);
209 }
...
CID 239687 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking options.envp suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
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 }
|
lpinca
approved these changes
Apr 22, 2022
tniessen
approved these changes
Apr 22, 2022
RaisinTen
approved these changes
Apr 24, 2022
Collaborator
Collaborator
|
Landed in 503f147 |
xtx1130
pushed a commit
to xtx1130/node
that referenced
this pull request
Apr 25, 2022
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 <[email protected]> PR-URL: nodejs#42819 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
targos
pushed a commit
that referenced
this pull request
Apr 28, 2022
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 <[email protected]> PR-URL: #42819 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
juanarbol
pushed a commit
that referenced
this pull request
May 31, 2022
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 <[email protected]> PR-URL: #42819 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
danielleadams
pushed a commit
that referenced
this pull request
Jun 27, 2022
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 <[email protected]> PR-URL: #42819 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
targos
pushed a commit
that referenced
this pull request
Jul 12, 2022
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 <[email protected]> PR-URL: #42819 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
targos
pushed a commit
that referenced
this pull request
Jul 31, 2022
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 <[email protected]> PR-URL: #42819 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
guangwong
pushed a commit
to noslate-project/node
that referenced
this pull request
Oct 10, 2022
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 <[email protected]> PR-URL: nodejs/node#42819 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 [email protected]