pidgin/pidgin

Fix leaks in preferences window

15 months ago, Elliott Sales de Andrade
bc9f3f1dd14b
file isExecutable
Fix leaks in preferences window

This fixes two leaks (of various amounts):
```
90 bytes in 5 blocks are definitely lost in loss record 27,394 of 41,972
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4995602: g_strdup (gstrfuncs.c:363)
by 0x4DE1EEC: value_lcopy_string.lto_priv.0 (gvaluetypes.c:315)
by 0x4DC7F13: g_object_get_valist (gobject.c:2893)
by 0x4DC8243: g_object_get (gobject.c:2988)
by 0x4CF53A1: purple_media_element_info_get_name (mediamanager.c:2404)
by 0x48BE32A: populate_vv_device_menuitems (pidginvvprefs.c:87)
by 0x48BF440: bind_vv_dropdown (pidginvvprefs.c:443)
by 0x48BF48B: bind_vv_frame (pidginvvprefs.c:454)
by 0x48BFA7F: pidgin_vv_prefs_init (pidginvvprefs.c:574)
by 0x4DDF0E7: g_type_create_instance (gtype.c:1931)
```
```
121 bytes in 5 blocks are definitely lost in loss record 31,627 of 41,972
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4995602: g_strdup (gstrfuncs.c:363)
by 0x4DE1EEC: value_lcopy_string.lto_priv.0 (gvaluetypes.c:315)
by 0x4DC7F13: g_object_get_valist (gobject.c:2893)
by 0x4DC8243: g_object_get (gobject.c:2988)
by 0x4CF5334: purple_media_element_info_get_id (mediamanager.c:2395)
by 0x48BE33A: populate_vv_device_menuitems (pidginvvprefs.c:88)
by 0x48BF440: bind_vv_dropdown (pidginvvprefs.c:443)
by 0x48BF48B: bind_vv_frame (pidginvvprefs.c:454)
by 0x48BFA7F: pidgin_vv_prefs_init (pidginvvprefs.c:574)
by 0x4DDF0E7: g_type_create_instance (gtype.c:1931)
```

Testing Done:
Ran with valgrind, opened the Preferences window, and the leaks were gone.

Reviewed at https://reviews.imfreedom.org/r/2303/
#!/usr/bin/env python3
#
# Purple is the legal property of its developers, whose names are too numerous
# to list here. Please refer to the COPYRIGHT file distributed with this
# source distribution.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
"""
Produce meson-config.h in a build directory.
This should not really be run manually. It is used by Meson as a
post-configuration script to create meson-config.h which for now simply
contains information about the configuration used to create the build
directory.
"""
import html
import json
import os
import shlex
import subprocess
import sys
try:
introspect = os.environ['MESONINTROSPECT']
except KeyError:
print('Meson is too old; '
'it does not set MESONINTROSPECT for postconf scripts.')
sys.exit(1)
else:
introspect = shlex.split(introspect)
try:
build_root = os.environ['MESON_BUILD_ROOT']
except KeyError:
print('Meson is too old; '
'it does not set MESON_BUILD_ROOT for postconf scripts.')
sys.exit(1)
def tostr(obj):
if isinstance(obj, str):
return html.escape(repr(obj))
else:
return repr(obj)
conf = subprocess.check_output(introspect + ['--buildoptions', build_root],
universal_newlines=True)
conf = json.loads(conf)
settings = ' '.join('{}={}'.format(option['name'], tostr(option['value']))
for option in sorted(conf, key=lambda x: x['name']))
with open(os.path.join(build_root, 'meson-config.h'), 'w') as f:
f.write('#define MESON_ARGS "{}"'.format(settings))