[vlc-commits] directsound: Remove xrealloc/abort usages

Hugo Beauzée-Luyssen git at videolan.org
Tue Feb 14 15:37:57 CET 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Feb 14 14:16:56 2017 +0100| [dc1f03424e7c320fbc00f55fe931097b231f3a1e] | committer: Jean-Baptiste Kempf

directsound: Remove xrealloc/abort usages

Also check for allocation failure before using the pointer
CID #1402750

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dc1f03424e7c320fbc00f55fe931097b231f3a1e
---

 modules/audio_output/directsound.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index 80be4ef..967971a 100644
--- a/modules/audio_output/directsound.c
+++ b/modules/audio_output/directsound.c
@@ -36,6 +36,7 @@
 #include <vlc_plugin.h>
 #include <vlc_aout.h>
 #include <vlc_charset.h>
+#include <vlc_memory.h>
 
 #include "audio_output/windows_audio_common.h"
 #include "audio_output/mmdevice.h"
@@ -1010,12 +1011,17 @@ static int CALLBACK DeviceEnumCallback( LPGUID guid, LPCWSTR desc,
         return true;
 
     list->count++;
-    list->ids = xrealloc( list->ids, list->count * sizeof(char *) );
-    list->names = xrealloc( list->names, list->count * sizeof(char *) );
+    list->ids = realloc_or_free( list->ids, list->count * sizeof(char *) );
+    if( list->ids == NULL )
+        return false;
+    list->names = realloc_or_free( list->names, list->count * sizeof(char *) );
+    if( list->names == NULL )
+    {
+        free( list->ids );
+        return false;
+    }
     list->ids[list->count - 1] = FromWide( buf );
     list->names[list->count - 1] = FromWide( desc );
-    if( list->ids == NULL || list->names == NULL )
-        abort();
 
     (void) mod;
     return true;



More information about the vlc-commits mailing list