changeset 433:0969d4ef0a34

malloc->calloc at wf/bih allocation
author arpi_esp
date Sun, 15 Apr 2001 14:45:15 +0000
parents 5251b0c57e39
children 50955d1a56c1
files aviheader.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/aviheader.c	Sun Apr 15 14:33:49 2001 +0000
+++ b/aviheader.c	Sun Apr 15 14:45:15 2001 +0000
@@ -56,8 +56,9 @@
       break; }
     case ckidSTREAMFORMAT: {      // read 'strf'
       if(last_fccType==streamtypeVIDEO){
-        sh_video->bih=malloc(chunksize); memset(sh_video->bih,0,chunksize);
-        if(verbose>=2) printf("found 'bih', %d bytes of %d\n",chunksize,sizeof(BITMAPINFOHEADER));
+        sh_video->bih=calloc((chunksize<sizeof(BITMAPINFOHEADER))?sizeof(BITMAPINFOHEADER):chunksize,1);
+//        sh_video->bih=malloc(chunksize); memset(sh_video->bih,0,chunksize);
+        if(verbose>=1) printf("found 'bih', %d bytes of %d\n",chunksize,sizeof(BITMAPINFOHEADER));
         stream_read(demuxer->stream,(char*) sh_video->bih,chunksize);
         chunksize=0;
 //        sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
@@ -65,8 +66,9 @@
 //        if(demuxer->video->id==-1) demuxer->video->id=stream_id;
       } else
       if(last_fccType==streamtypeAUDIO){
-        sh_audio->wf=malloc(chunksize); memset(sh_audio->wf,0,chunksize);
-        if(verbose>=2) printf("found 'wf', %d bytes of %d\n",chunksize,sizeof(WAVEFORMATEX));
+        sh_audio->wf=calloc((chunksize<sizeof(WAVEFORMATEX))?sizeof(WAVEFORMATEX):chunksize,1);
+//        sh_audio->wf=malloc(chunksize); memset(sh_audio->wf,0,chunksize);
+        if(verbose>=1) printf("found 'wf', %d bytes of %d\n",chunksize,sizeof(WAVEFORMATEX));
         stream_read(demuxer->stream,(char*) sh_audio->wf,chunksize);
         chunksize=0;
         if(verbose>=1) print_wave_header(sh_audio->wf);