changeset 18051:110105412f8f

use calloc instead of malloc - simplifies code and fixes overflow problems. Path by Bjorn Sandell (biorn at chalmers se)
author reimar
date Thu, 06 Apr 2006 20:56:35 +0000
parents d437b070b8a7
children be163e9c9bca
files libmpdemux/aviheader.c
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/aviheader.c	Thu Apr 06 20:36:39 2006 +0000
+++ b/libmpdemux/aviheader.c	Thu Apr 06 20:56:35 2006 +0000
@@ -206,7 +206,6 @@
       break; }
     case mmioFOURCC('i', 'n', 'd', 'x'): {
       uint32_t i;
-      unsigned msize = 0;
       avisuperindex_chunk *s;
       priv->suidx_size++;
       priv->suidx = realloc(priv->suidx, priv->suidx_size * sizeof (avisuperindex_chunk));
@@ -235,11 +234,8 @@
           mp_msg (MSGT_HEADER, MSGL_WARN, "Broken super index chunk size: %u\n",s->wLongsPerEntry);
           s->wLongsPerEntry = sizeof(avisuperindex_entry)/4;
       }
-      msize = sizeof (avisuperindex_entry) * s->nEntriesInUse;
-      s->aIndex = malloc(msize);
-      memset (s->aIndex, 0, msize);
-      s->stdidx = malloc (s->nEntriesInUse * sizeof (avistdindex_chunk));
-      memset (s->stdidx, 0, s->nEntriesInUse * sizeof (avistdindex_chunk));
+      s->aIndex = calloc(s->nEntriesInUse, sizeof (avisuperindex_entry));
+      s->stdidx = calloc(s->nEntriesInUse, sizeof (avistdindex_chunk));
 
       // now the real index of indices
       for (i=0; i<s->nEntriesInUse; i++) {