diff options
author | Christophe Guiraud <christophe.guiraud@intel.com> | 2013-03-25 16:22:05 +0100 |
---|---|---|
committer | Christophe Guiraud <christophe.guiraud@intel.com> | 2013-03-26 10:56:43 +0100 |
commit | 1fbb7baa1066720fb9782900bf70c0de55e0f944 (patch) | |
tree | c159765bc1e046201b35da45b6331921fd431902 /libdleyna/renderer/device.c | |
parent | a09c971d03348900880d9a672fae96468e47a7cc (diff) | |
download | dleyna-renderer-1fbb7baa1066720fb9782900bf70c0de55e0f944.tar.gz |
[Bug] Fix Valgrind reports memory corruption when Setting the Mute property
- Valgrind reports memory corruption when Setting the Mute property.
- If you set the Mute value, the received last change event only contains
a value for mute. It does not contain a value for Volume, and so
device_volume was not initialized.
- The fix consists in initializing device_volume with G_MAXUINT, so we can
check if the volume was part of the received last change event.
- Fix issue: https://github.com/01org/dleyna-renderer/issues/37
Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
Diffstat (limited to 'libdleyna/renderer/device.c')
-rw-r--r-- | libdleyna/renderer/device.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libdleyna/renderer/device.c b/libdleyna/renderer/device.c index ee6b1c6..5d9e649 100644 --- a/libdleyna/renderer/device.c +++ b/libdleyna/renderer/device.c @@ -1409,7 +1409,7 @@ static void prv_rc_last_change_cb(GUPnPServiceProxy *proxy, GVariantBuilder *changed_props_vb; GVariant *changed_props; GVariant *val; - guint device_volume; + guint dev_volume = G_MAXUINT; double mpris_volume; guint mute = G_MAXUINT; @@ -1419,7 +1419,7 @@ static void prv_rc_last_change_cb(GUPnPServiceProxy *proxy, parser, 0, g_value_get_string(value), NULL, - "Volume", G_TYPE_UINT, &device_volume, + "Volume", G_TYPE_UINT, &dev_volume, "Mute", G_TYPE_UINT, &mute, NULL)) goto on_error; @@ -1432,11 +1432,13 @@ static void prv_rc_last_change_cb(GUPnPServiceProxy *proxy, changed_props_vb = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); - mpris_volume = (double)device_volume / (double)device->max_volume; - val = g_variant_ref_sink(g_variant_new_double(mpris_volume)); - prv_change_props(device->props.player_props, - DLR_INTERFACE_PROP_VOLUME, val, - changed_props_vb); + if (dev_volume != G_MAXUINT) { + mpris_volume = (double)dev_volume / (double)device->max_volume; + val = g_variant_ref_sink(g_variant_new_double(mpris_volume)); + prv_change_props(device->props.player_props, + DLR_INTERFACE_PROP_VOLUME, val, + changed_props_vb); + } if (mute != G_MAXUINT) { val = g_variant_ref_sink( |