-
Notifications
You must be signed in to change notification settings - Fork 83
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
fix some FDs leaks #334
fix some FDs leaks #334
Conversation
Signed-off-by: Giuseppe Scrivano <[email protected]>
it is freed with "free" in different places, so allocate using the stdlib function. Signed-off-by: Giuseppe Scrivano <[email protected]>
it is allocated using g_malloc0 and passed to a list, that is later freed with g_free. Signed-off-by: Giuseppe Scrivano <[email protected]>
Signed-off-by: Giuseppe Scrivano <[email protected]>
Signed-off-by: Giuseppe Scrivano <[email protected]>
Signed-off-by: Giuseppe Scrivano <[email protected]>
@AkihiroSuda PTAL |
@@ -57,7 +60,7 @@ struct api_ctx { | |||
|
|||
struct api_ctx *api_ctx_alloc(struct slirp4netns_config *cfg) | |||
{ | |||
struct api_ctx *ctx = (struct api_ctx *)g_malloc0(sizeof(*ctx)); | |||
struct api_ctx *ctx = (struct api_ctx *)calloc(1, sizeof(*ctx)); |
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.
Why?
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.
g_malloc0 using malloc internally is just an implementation detail. Since we free ctx
with free
, we should either change g_malloc()
-> malloc()
, or free()
with g_free()
.
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
more information in each commit message.
Found by static analysis.