Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(512)

Issue 104850043: Fix string leaks in deserialize vfuncs (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years ago by fujiwara
Modified:
9 years, 12 months ago
Reviewers:
teuf, shawn.p.huang, Peng
CC:
shawn.p.huang_gmail.com, fujiwara, cfergeau_redhat.com
Base URL:
git://github.com/ibus/ibus.git@master
Visibility:
Public.

Description

Fix string leaks in deserialize vfuncs When an object contains char * properties, its deserialize function will overwrite these string values without freeing them first. They are not necessarily NULL as they can have (default) values set upon construction, so they need to be g_free'd before being overwritten. For example, IBusEngineDesc::longname, IBusEngineDesc::description, IBusEngineDesc::language, ... are all set to "" upon construction (instead of NULL), so the corresponding IBusEngineDesc fields must be freed before being overwritten during deserialization. This commit introduces a ibus_g_variant_get_child_string() to do this and set the string value. This leak was reported by valgrind: ==22163== 59 bytes in 59 blocks are definitely lost in loss record 1,633 of 2,720 ==22163== at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==22163== by 0x56DFDF2: g_malloc (gmem.c:97) ==22163== by 0x56E011D: g_malloc_n (gmem.c:338) ==22163== by 0x56FAFCC: g_strdup (gstrfuncs.c:356) ==22163== by 0x546CDB8: g_value_dup_string (gvaluetypes.c:1136) ==22163== by 0x4E43A98: ibus_engine_desc_set_property (ibusenginedesc.c:385) ==22163== by 0x5446CA3: object_set_property (gobject.c:1378) ==22163== by 0x54484BB: g_object_constructor (gobject.c:2020) ==22163== by 0x4E24564: ibus_object_constructor (ibusobject.c:111) ==22163== by 0x5447577: g_object_new_with_custom_constructor (gobject.c:1645) ==22163== by 0x5447787: g_object_new_internal (gobject.c:1722) ==22163== by 0x5447C75: g_object_newv (gobject.c:1868) ==22163== by 0x544737A: g_object_new (gobject.c:1568) ==22163== by 0x4E2521C: ibus_serializable_deserialize (ibusserializable.c:292) ==22163== by 0x4E480E0: ibus_component_deserialize (ibuscomponent.c:408) ==22163== by 0x4E2523E: ibus_serializable_deserialize (ibusserializable.c:294) ==22163== by 0x4E4C1D1: ibus_registry_deserialize (ibusregistry.c:202) ==22163== by 0x4E4C95C: ibus_registry_load_cache_file (ibusregistry.c:362) ==22163== by 0x4E4C6A4: ibus_registry_load_cache (ibusregistry.c:302) ==22163== by 0x40EBCD: bus_ibus_impl_registry_init (ibusimpl.c:1871) ==22163== by 0x40C1D4: bus_ibus_impl_init (ibusimpl.c:424) ==22163== by 0x5460FCD: g_type_create_instance (gtype.c:1868) ==22163== by 0x5448466: g_object_constructor (gobject.c:2006) ==22163== by 0x4E24564: ibus_object_constructor (ibusobject.c:111) ==22163== by 0x5447577: g_object_new_with_custom_constructor (gobject.c:1645) ==22163== by 0x5447787: g_object_new_internal (gobject.c:1722) ==22163== by 0x54483C1: g_object_new_valist (gobject.c:1980) ==22163== by 0x54473C9: g_object_new (gobject.c:1571) ==22163== by 0x40E94A: bus_ibus_impl_get_default (ibusimpl.c:1807) ==22163== by 0x41D880: bus_server_init (server.c:100) ==22163== by 0x420E91: main (main.c:236) BUG=http://code.google.com/p/ibus/issues/detail?id=1712

Patch Set 1 #

Total comments: 3

Patch Set 2 : Updated with comment #3. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+64 lines, -25 lines) Patch
M src/ibuscomponent.c View 1 2 chunks +17 lines, -8 lines 0 comments Download
M src/ibusenginedesc.c View 1 2 chunks +31 lines, -15 lines 0 comments Download
M src/ibusinternal.h View 1 chunk +3 lines, -0 lines 0 comments Download
M src/ibusobservedpath.c View 2 chunks +2 lines, -1 line 0 comments Download
M src/ibusproperty.c View 2 chunks +2 lines, -1 line 0 comments Download
M src/ibusutil.c View 1 chunk +9 lines, -0 lines 0 comments Download

Messages

Total messages: 4
fujiwara
10 years ago (2014-06-04 07:25:27 UTC) #1
Peng
lgtm with nits https://codereview.appspot.com/104850043/diff/1/src/ibuscomponent.c File src/ibuscomponent.c (right): https://codereview.appspot.com/104850043/diff/1/src/ibuscomponent.c#newcode395 src/ibuscomponent.c:395: ibus_g_variant_get_child_string (variant, retval++, &component->priv->textdomain); Some lines ...
9 years, 12 months ago (2014-06-05 14:39:06 UTC) #2
teuf
https://codereview.appspot.com/104850043/diff/1/src/ibuscomponent.c File src/ibuscomponent.c (right): https://codereview.appspot.com/104850043/diff/1/src/ibuscomponent.c#newcode395 src/ibuscomponent.c:395: ibus_g_variant_get_child_string (variant, retval++, &component->priv->textdomain); On 2014/06/05 14:39:06, Peng wrote: ...
9 years, 12 months ago (2014-06-05 21:26:34 UTC) #3
fujiwara
9 years, 12 months ago (2014-06-06 07:16:27 UTC) #4
https://codereview.appspot.com/104850043/diff/1/src/ibuscomponent.c
File src/ibuscomponent.c (right):

https://codereview.appspot.com/104850043/diff/1/src/ibuscomponent.c#newcode395
src/ibuscomponent.c:395: ibus_g_variant_get_child_string (variant, retval++,
&component->priv->textdomain);
On 2014/06/05 21:26:34, teuf wrote:
> On 2014/06/05 14:39:06, Peng wrote:
> > Some lines are more than 80 chars. And other places.
> 
> I've fixed that locally, but I don't know how to attach an updated patch here
:(
> Should I attach that to the ticket I opened on google code ?

I integrated your patch.
If you will file another patch, you could use git-cl directly.
The usage of git-cl is described in the commit log:

% cd ibus
% git log codereview.settings
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b