# HG changeset patch # User reimar # Date 1144356995 0 # Node ID 110105412f8f11e0b1898076ac7a5a3ee4c83fdc # Parent d437b070b8a7100db70456041d7b5321bc16f5c2 use calloc instead of malloc - simplifies code and fixes overflow problems. Path by Bjorn Sandell (biorn at chalmers se) diff -r d437b070b8a7 -r 110105412f8f libmpdemux/aviheader.c --- 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; inEntriesInUse; i++) {