hal: Fix memory leak in listen module
String returned from str_parms_to_str for set/get parameter
key-value pair for listen module is not de-allocated. Fix is
to make sure the memory allocated for key value pair
is de-allocated.
CRs-Fixed: 610083
Change-Id: I290e61168b8fd1569a7b89e13257e142aa5aa1ac
diff --git a/hal/audio_extn/listen.c b/hal/audio_extn/listen.c
index 9166f8e..4a1980b 100644
--- a/hal/audio_extn/listen.c
+++ b/hal/audio_extn/listen.c
@@ -119,10 +119,13 @@
void audio_extn_listen_set_parameters(struct audio_device *adev,
struct str_parms *parms)
{
- ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
+ ALOGV("%s: enter", __func__);
if (listen_dev) {
- listen_dev->listen_set_parameters(&adev->device, str_parms_to_str(parms));
+ char *kv_pairs = str_parms_to_str(parms);
+ ALOGV_IF(kv_pairs != NULL, "%s: %s", __func__, kv_pairs);
+ listen_dev->listen_set_parameters(&adev->device, kv_pairs);
+ free(kv_pairs);
}
return;