Branch: refs/heads/master
  Home:   https://github.com/ibus/ibus
  Commit: f3e8aaff559e56efe54c43af123e0ab87a17423b
      
https://github.com/ibus/ibus/commit/f3e8aaff559e56efe54c43af123e0ab87a17423b
  Author: Christophe Fergeau <[email protected]>
  Date:   2014-06-06 (Fri, 06 Jun 2014)

  Changed paths:
    M src/ibuscomponent.c
    M src/ibusenginedesc.c
    M src/ibusinternal.h
    M src/ibusobservedpath.c
    M src/ibusproperty.c
    M src/ibusutil.c

  Log Message:
  -----------
  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

Review URL: https://codereview.appspot.com/104850043
Patch from Christophe Fergeau <[email protected]>.


-- 
-- 
You received this message because you are subscribed to the Google
Groups "ibus-devel" group.
iBus project web page: http://code.google.com/p/ibus/
iBus dev group: http://groups.google.com/group/ibus-devel?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"ibus-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

回复