Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

wyjwang
Copy link
Contributor

@wyjwang wyjwang commented Feb 27, 2020

Client: c_glib
Patch: wangyunjian

Signed-off-by: wangyunjian wangyunjian@huawei.com

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
Copy link
Contributor

@allengeorge allengeorge Mar 30, 2020

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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;
}
}

@stale
Copy link

stale bot commented May 30, 2020

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.

@stale stale bot added the wontfix label May 30, 2020
@Jens-G Jens-G removed the wontfix label May 30, 2020
@stale
Copy link

stale bot commented Jul 29, 2020

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.

@stale stale bot added the wontfix label Jul 29, 2020
@stale
Copy link

stale bot commented Aug 8, 2020

This issue has been automatically closed due to inactivity. Thank you for your contributions.

@stale stale bot closed this Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants