-
Notifications
You must be signed in to change notification settings - Fork 63
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 potential memory leak in ccn-lite-ctrl.c #341
Conversation
src/ccnl-utils/src/ccn-lite-ctrl.c
Outdated
port = strtol(strtok(NULL, "/"), NULL, 0); | ||
use_udp = 1; | ||
printf("udp: <%s> <%i>\n", udp, port); | ||
|
||
/** if memory has been allocated previously, free it */ | ||
if (udp_temp) { |
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.
Isn't udp_temp
always non-NULL
here? Is this check necessary?
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 Malloc returns NULL in strdup because system is out of memory it can be NULL
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.
But there is a check for that only 9 lines above ..
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.
Right. Missed that. So, we can remove that.
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.
Remove unnecessary check, see comments
b886400
to
f31818b
Compare
Has been addressed with the latest updated commit (rebased, push -f) @blacksheeep Could you please approve the PR? |
Contribution description
The PR checks if a call to
strdup
failed and also introduces a new variable which stores the newly allocated memory before it is overwritten again by a call tostrtok
and thus, the memory allocated bystrdup
can't be freed anymore.Issues/PRs references
Fixes #327