-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes from Coverity Report (12/01/2017) #66
Open
RanierV
wants to merge
7
commits into
nginx:master
Choose a base branch
from
RanierV:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2ee3265
Update nxt_conn_write.c
RanierV 676ab95
Update nxt_php_sapi.c
RanierV ec6cdeb
Update nxt_time_parse.c
RanierV 858cb4d
Update nxt_socketpair.c
RanierV 9173b78
Update nxt_process_title.c
RanierV a67463b
Update nxt_linux_sendfile.c
RanierV d28a21b
Update nxt_event_conn_job_sendfile.c
RanierV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update nxt_process_title.c
CID 200480 (#2 of 2): Resource leak (RESOURCE_LEAK)22. leaked_storage: Variable p going out of scope leaks the storage it points to.
- Loading branch information
commit 9173b78be5fee9308f302de890fc43363b29f160
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,11 +116,6 @@ nxt_process_arguments(nxt_task_t *task, char **orig_argv, char ***orig_envp) | |
} | ||
} | ||
|
||
p = nxt_malloc(strings_size); | ||
if (p == NULL) { | ||
return; | ||
} | ||
|
||
if (argv_end == end) { | ||
/* | ||
* There is no reason to modify environ if arguments | ||
|
@@ -130,6 +125,11 @@ nxt_process_arguments(nxt_task_t *task, char **orig_argv, char ***orig_envp) | |
goto done; | ||
} | ||
|
||
p = nxt_malloc(strings_size); | ||
if (p == NULL) { | ||
goto done; | ||
} | ||
|
||
end = argv[0]; | ||
|
||
for (i = 0; argv[i] != NULL; i++) { | ||
|
@@ -149,7 +149,7 @@ nxt_process_arguments(nxt_task_t *task, char **orig_argv, char ***orig_envp) | |
|
||
env = nxt_malloc(environ_size); | ||
if (env == NULL) { | ||
return; | ||
goto done; | ||
} | ||
|
||
/* | ||
|
@@ -178,6 +178,12 @@ nxt_process_arguments(nxt_task_t *task, char **orig_argv, char ***orig_envp) | |
} | ||
|
||
done: | ||
if (p != NULL) { | ||
nxt_free(p); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, I just saw this old PR around, and had a fast look at it. nxt_free(), as well as free(3), can handle NULL just fine. The conditionals are not necessary. |
||
} | ||
if (env != NULL) { | ||
nxt_free(env); | ||
} | ||
|
||
/* Preserve space for the trailing zero. */ | ||
end--; | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you move
p
after the othergoto done
, you'll arrive atnxt_free()
with an uninitialized pointer, which will result in Undefined Behavior.That is, consider you jump to
done
from line 125 after this patch. You'll freep
, which is uninitialized, and contains a random value. That will likely crash.