use calloc instead of malloc - simplifies code and fixes overflow problems.

Path by Bjorn Sandell (biorn at chalmers se)


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18052 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2006-04-06 20:56:35 +00:00
parent 9ec42a7e3f
commit 9641a1433c
1 changed files with 2 additions and 6 deletions

View File

@ -206,7 +206,6 @@ while(1){
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 @@ while(1){
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++) {