-
Notifications
You must be signed in to change notification settings - Fork 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
THRIFT-5122: Fix memory leak in c_glib tutorial server #2037
Conversation
Client: c_glib Patch: wangyunjian Signed-off-by: wangyunjian <wangyunjian@huawei.com>
NULL); | ||
result = FALSE; | ||
|
||
/* Note the call to g_strdup above: All the memory used by a |
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.
@wyjwang Is this comment not valid any more? IOW, does no one ever free *ouch
?
Is the actual problem that the generated handling code should free *ouch
if it's defined, and that's the source of the leak?
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.
I'm actually very confused about the memory model in the c_glib code: whose responsibility is it to free allocated memory? Is it the generated handling code?
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.
Yes,the generated handling code will malloc memory in its set_property fuction and free memory in its finalize fuction.
static void
invalid_operation_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
InvalidOperation *self = INVALID_OPERATION (object);
switch (property_id)
{
case PROP_INVALID_OPERATION_WHAT_OP:
self->whatOp = g_value_get_int (value);
self->__isset_whatOp = TRUE;
break;
case PROP_INVALID_OPERATION_WHY:
if (self->why != NULL)
g_free (self->why);
self->why = g_value_dup_string (value);
self->__isset_why = TRUE;
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
invalid_operation_finalize (GObject *object)
{
InvalidOperation *tobject = INVALID_OPERATION (object);
/* satisfy -Wall in case we don't use tobject */
THRIFT_UNUSED_VAR (tobject);
if (tobject->why != NULL)
{
g_free(tobject->why);
tobject->why = NULL;
}
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed due to inactivity. Thank you for your contributions. |
Client: c_glib
Patch: wangyunjian
Signed-off-by: wangyunjian wangyunjian@huawei.com