[vlc-commits] auhal: fix memleak, check malloc return value
David Fuhrmann
git at videolan.org
Tue Dec 30 16:12:00 CET 2014
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sun Dec 28 17:21:10 2014 +0100| [4e2aec4c215f1ce4ee3679a5431fde331aff4bee] | committer: David Fuhrmann
auhal: fix memleak, check malloc return value
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4e2aec4c215f1ce4ee3679a5431fde331aff4bee
---
modules/audio_output/auhal.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 9bdd4fd..b7a751d 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -1265,8 +1265,13 @@ static void RebuildDeviceList(audio_output_t * p_aout)
}
length = CFStringGetLength(device_name_ref);
length++;
- psz_name = (char *)malloc(length);
+ psz_name = malloc(length);
+ if (!psz_name) {
+ CFRelease(device_name_ref);
+ return;
+ }
CFStringGetCString(device_name_ref, psz_name, length, kCFStringEncodingUTF8);
+ CFRelease(device_name_ref);
msg_Dbg(p_aout, "DevID: %i DevName: %s", deviceIDs[i], psz_name);
@@ -1296,7 +1301,6 @@ static void RebuildDeviceList(audio_output_t * p_aout)
// TODO: only register once for each device
ManageAudioStreamsCallback(p_aout, deviceIDs[i], true);
- CFRelease(device_name_ref);
free(psz_name);
}
More information about the vlc-commits
mailing list