-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix for Potential memory leak in class ServiceArgumentParser's Constructor #8367
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
Conversation
|
Reopen for CI fix |
directionless
left a comment
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.
Both before and after this PR, the same private method, |
|
i was trying to remove some of the older commits which are not related to this issue..ended up closing the PR, Apologies for the inconvenience caused. i can create a new PR and submit for review , please let me know your thoughts |
i too agree with this approach, freeing memory immediately rather than wait for the destructor also make sence, |
Feel free to open a new PR, I suggest not using the |
|
@pradishmp We are likely to cut a release in the next few days, I don't know if the timing will line up on your next PR, but there will always be another release. |
ok i will see if i can fix this today itself or we can always have this in next release, whichever works best for the product. |
Fixes #8351
What changed ?
This is a corner case scenario where there is a potential for a memory leak. For this leak to occur, two things must happen:
toMBString, which is used to convert the wide char strings to multibyte strings, should fail, returning anullptr.When a
nullptris returned, as part of cleaning up the heap memory allocated, thecleanArgs()function is called. However, this function will only clean up the memory if the Boolean variableowns_argv_ptrs is set to true. In this case, as the variable is still false, the function will only remove all elements from the vector.Later, when the Boolean variable
owns_argv_ptrsis set to true and the destructor gets a chance to clean up, it cannot do anything as the elements are already removed and the vector size is zero.Therefore, the fix is to remove the call to the function
clearArgs()and leave it to the destructor to clean up the memory.