diff options
author | Vidyakumar Athota <vathota@codeaurora.org> | 2012-09-10 18:11:46 -0700 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2012-09-24 15:10:04 -0700 |
commit | 855d9cadd88a1394c04cfe1cb5879266cfea9d40 (patch) | |
tree | 5455ad3e5d6d301cdfda26aa4dfa7ca12d089db6 | |
parent | 96a22234baf20cbd5b09e0fe42a8690ff9622883 (diff) | |
download | hardware_libhardware-855d9cadd88a1394c04cfe1cb5879266cfea9d40.zip hardware_libhardware-855d9cadd88a1394c04cfe1cb5879266cfea9d40.tar.gz hardware_libhardware-855d9cadd88a1394c04cfe1cb5879266cfea9d40.tar.bz2 |
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
-rw-r--r-- | include/hardware/audio.h | 7 |
1 files changed, 6 insertions, 1 deletions
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 |