hal: Fix memory leak in HAL debug logs
String returned from str_parms_to_str for set/get parameter in
debug logs is not de-allocated. Fix is to make sure the memory
allocated for set parameter key value pair is de-allocated.
CRs-Fixed: 610079
Change-Id: I5027d8f1741c9e7223e7b4721f8d5473404998d3
diff --git a/hal/voice.c b/hal/voice.c
index 8783f01..28d44db 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -364,8 +364,9 @@
char value[32];
int val;
int ret = 0, err;
+ char *kv_pairs = str_parms_to_str(parms);
- ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
+ ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
ret = voice_extn_set_parameters(adev, parms);
if (ret != 0)
@@ -413,6 +414,7 @@
done:
ALOGV("%s: exit with code(%d)", __func__, ret);
+ free(kv_pairs);
return ret;
}