Sanitizer reported memory leak for '--invalid' option or port number is missed cases to redis-server.#12322
Conversation
src/config.c
Outdated
| sdsfreesplitres(argv,argc); | ||
| goto loaderr; |
There was a problem hiding this comment.
Aren't every other goto loaderr a problem? I would rather us add a check in loaderr saying if (argv) sdsfreesplitres(argv,argc); Then add all of these on every line.
There was a problem hiding this comment.
Hi @madolson ,
I agree with you, I have already started checking for other cases. I will add as you mentioned and test.
There was a problem hiding this comment.
can't we put the cleanup in the loaderr label, and nullify something in the (i assume fewer) other places that we call sdsfreesplitres). this will result in fewer changes, and safer code.
There was a problem hiding this comment.
Hi @oranagra ,
argv and argc are declared in for loop so if we try to free in loaderr, pointer and variable is going out of scope. In order to do we have to bring argv and argc to function scope. I feel its safe to bring them, I will change scope and test all the cases, if everything works fine will update the diff. Thanks!
There was a problem hiding this comment.
We can move the declaration up outside of the loop.
|
Hi @madolson , |
|
just to make sure, this isn't really a leak (the process is being terminated), it's just done to keep things clean, and keep valgrind happy, right? |
|
Yes, you're right @oranagra, it is related to clean up missing prior process is being terminated, updated the top summary and also updated the diff. Thanks! |
Observed that the sanitizer reported memory leak as clean up is not done before the process termination in negative/following cases:
- when we passed '--invalid' as option to redis-server.
- when we pass '--port' as option and missed to add port number to redis-server.
As part analysis found that the sdsfreesplitres is not called when this condition checks are being hit.
Output after the fix: