From 855d9cadd88a1394c04cfe1cb5879266cfea9d40 Mon Sep 17 00:00:00 2001 From: Vidyakumar Athota Date: Mon, 10 Sep 2012 18:11:46 -0700 Subject: libhardware:Fix for memory leak by get_parameters call - get_parameters call uses strdup which allocate memory for string. Its caller function responsibility to free the memory which is not happened now - Fix: free the memory created by get_parameters call Change-Id: I15423f451e7bf817a7bcf755c0115d2e53ba7947 CRS-Fixed: 397789 --- include/hardware/audio.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/hardware/audio.h b/include/hardware/audio.h index b8f3512..1533ee1 100644 --- a/include/hardware/audio.h +++ b/include/hardware/audio.h @@ -384,6 +384,8 @@ static inline size_t audio_stream_frame_size(struct audio_stream *s) size_t chan_samp_sz; uint32_t chan_mask = s->get_channels(s); int format = s->get_format(s); + char *tmpparam; + int isParamEqual; #ifdef QCOM_HARDWARE if (audio_is_input_channel(chan_mask)) { @@ -391,7 +393,10 @@ static inline size_t audio_stream_frame_size(struct audio_stream *s) AUDIO_CHANNEL_IN_MONO ); } - if(!strcmp(s->get_parameters(s, "voip_flag"),"voip_flag=1")) { + tmpparam = s->get_parameters(s, "voip_flag"); + isParamEqual = !strcmp(tmpparam,"voip_flag=1"); + free(tmpparam); + if(isParamEqual) { if(format != AUDIO_FORMAT_PCM_8_BIT) return popcount(chan_mask) * sizeof(int16_t); else -- cgit v1.1