changeset 27214:e2f7de85ebfb

Clean up reading of wav extradata. Fixes bug #1135
author reimar
date Thu, 10 Jul 2008 19:29:02 +0000
parents aa7edc57c75e
children 3fce9487d1bb
files libmpdemux/demux_audio.c
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_audio.c	Thu Jul 10 15:37:06 2008 +0000
+++ b/libmpdemux/demux_audio.c	Thu Jul 10 19:29:02 2008 +0000
@@ -391,19 +391,15 @@
     sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec;
     l -= 16;
     if (l > 0) {
-    w->cbSize = stream_read_word_le(s);
+    w->cbSize = FFMAX(stream_read_word_le(s), 0);
     l -= 2;
-     if (w->cbSize > 0) {
       if (l < w->cbSize) {
         mp_msg(MSGT_DEMUX,MSGL_ERR,"[demux_audio] truncated extradata (%d < %d)\n",
 	l,w->cbSize);
-        stream_read(s,(char*)((char*)(w)+sizeof(WAVEFORMATEX)),l);
-        l = 0;
-      } else {
+        l = w->cbSize;
+      }
         stream_read(s,(char*)((char*)(w)+sizeof(WAVEFORMATEX)),w->cbSize);
         l -= w->cbSize;
-      }
-     }
     }
 
     if( mp_msg_test(MSGT_DEMUX,MSGL_V) ) print_wave_header(w, MSGL_V);