[MPlayer-cvslog] r27799 - in trunk/libmpcodecs: ad_twin.c dec_audio.c

reimar subversion at mplayerhq.hu
Sat Oct 18 20:54:05 CEST 2008


Author: reimar
Date: Sat Oct 18 20:54:05 2008
New Revision: 27799

Log:
Use av_malloc/av_free for audio-related buffers to avoid crashes due to
insufficient alignment on systems without memalign.


Modified:
   trunk/libmpcodecs/ad_twin.c
   trunk/libmpcodecs/dec_audio.c

Modified: trunk/libmpcodecs/ad_twin.c
==============================================================================
--- trunk/libmpcodecs/ad_twin.c	(original)
+++ trunk/libmpcodecs/ad_twin.c	Sat Oct 18 20:54:05 2008
@@ -138,7 +138,7 @@ static int init_vqf_audio_codec(sh_audio
     priv->framesize=TvqGetFrameSize();
     sh_audio->audio_in_minsize=priv->framesize*in_fmt->nChannels;
     sh_audio->a_in_buffer_size=4*sh_audio->audio_in_minsize;
-    sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
+    sh_audio->a_in_buffer=av_malloc(sh_audio->a_in_buffer_size);
     sh_audio->a_in_buffer_len=0;
 
 

Modified: trunk/libmpcodecs/dec_audio.c
==============================================================================
--- trunk/libmpcodecs/dec_audio.c	(original)
+++ trunk/libmpcodecs/dec_audio.c	Sat Oct 18 20:54:05 2008
@@ -74,8 +74,7 @@ static int init_audio_codec(sh_audio_t *
 	sh_audio->a_in_buffer_size = sh_audio->audio_in_minsize;
 	mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_AllocatingBytesForInputBuffer,
 	       sh_audio->a_in_buffer_size);
-	sh_audio->a_in_buffer = memalign(16, sh_audio->a_in_buffer_size);
-	memset(sh_audio->a_in_buffer, 0, sh_audio->a_in_buffer_size);
+	sh_audio->a_in_buffer = av_mallocz(sh_audio->a_in_buffer_size);
 	sh_audio->a_in_buffer_len = 0;
     }
 
@@ -84,12 +83,11 @@ static int init_audio_codec(sh_audio_t *
     mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_AllocatingBytesForOutputBuffer,
 	   sh_audio->audio_out_minsize, MAX_OUTBURST, sh_audio->a_buffer_size);
 
-    sh_audio->a_buffer = memalign(16, sh_audio->a_buffer_size);
+    sh_audio->a_buffer = av_mallocz(sh_audio->a_buffer_size);
     if (!sh_audio->a_buffer) {
 	mp_msg(MSGT_DECAUDIO, MSGL_ERR, MSGTR_CantAllocAudioBuf);
 	return 0;
     }
-    memset(sh_audio->a_buffer, 0, sh_audio->a_buffer_size);
     sh_audio->a_buffer_len = 0;
 
     if (!sh_audio->ad_driver->init(sh_audio)) {
@@ -306,12 +304,8 @@ void uninit_audio(sh_audio_t *sh_audio)
     free(sh_audio->a_out_buffer);
     sh_audio->a_out_buffer = NULL;
     sh_audio->a_out_buffer_size = 0;
-    if (sh_audio->a_buffer)
-	free(sh_audio->a_buffer);
-    sh_audio->a_buffer = NULL;
-    if (sh_audio->a_in_buffer)
-	free(sh_audio->a_in_buffer);
-    sh_audio->a_in_buffer = NULL;
+    av_freep(&sh_audio->a_buffer);
+    av_freep(&sh_audio->a_in_buffer);
 }
 
 



More information about the MPlayer-cvslog mailing list