-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[C][Client] Free list or map memory when json parsing fails #11866
[C][Client] Free list or map memory when json parsing fails #11866
Conversation
keyValuePair_t *localKeyValue = (keyValuePair_t*) listEntry->data; | ||
free(localKeyValue->key); | ||
localKeyValue->key = NULL; | ||
free(localKeyValue->value); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Thanks. I'll deal by data type.
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.
Done. Can you take another look ?
@ityuhui |
130471d
to
6bcb191
Compare
Hi @zhemant Can you check the new code changes? I have updated based on your comments. |
Thank you for the changes @ityuhui. If we are planning to support primitive types(string, byteArray, enum, number, boolean) then these changes are sufficient, I would recommend we add a non-primitive section where we add a comment line https://swagger.io/docs/specification/data-models/dictionaries/ |
* Note for unsupported data type
Thanks @zhemant I addressed this comment by the commit a76b542 |
I have logged a bug kubernetes-client/c#112 for the non-primitive data in the map. I will implement it in future. |
Is this PR ready to merge now ? @zhemant |
Thanks for the changes @ityuhui . LGTM |
Tested locally and C petstore built without issues. |
When a list or map JSON cannot to be parsed successfully, the original code will goto the end of function
*_parseFromJSON
without freeing the memory of the list or map.This PR fixes this memory leak.
@wing328 @zhemant @michelealbano
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
(5.3.0),6.0.x