comparison libmpdemux/aviheader.c @ 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
comparison
equal deleted inserted replaced
18050:d437b070b8a7 18051:110105412f8f
204 last_fccType=h.fccType; 204 last_fccType=h.fccType;
205 if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_strh(&h,MSGL_V); 205 if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_strh(&h,MSGL_V);
206 break; } 206 break; }
207 case mmioFOURCC('i', 'n', 'd', 'x'): { 207 case mmioFOURCC('i', 'n', 'd', 'x'): {
208 uint32_t i; 208 uint32_t i;
209 unsigned msize = 0;
210 avisuperindex_chunk *s; 209 avisuperindex_chunk *s;
211 priv->suidx_size++; 210 priv->suidx_size++;
212 priv->suidx = realloc(priv->suidx, priv->suidx_size * sizeof (avisuperindex_chunk)); 211 priv->suidx = realloc(priv->suidx, priv->suidx_size * sizeof (avisuperindex_chunk));
213 s = &priv->suidx[priv->suidx_size-1]; 212 s = &priv->suidx[priv->suidx_size-1];
214 213
233 // Check and fix this useless crap 232 // Check and fix this useless crap
234 if(s->wLongsPerEntry != sizeof (avisuperindex_entry)/4) { 233 if(s->wLongsPerEntry != sizeof (avisuperindex_entry)/4) {
235 mp_msg (MSGT_HEADER, MSGL_WARN, "Broken super index chunk size: %u\n",s->wLongsPerEntry); 234 mp_msg (MSGT_HEADER, MSGL_WARN, "Broken super index chunk size: %u\n",s->wLongsPerEntry);
236 s->wLongsPerEntry = sizeof(avisuperindex_entry)/4; 235 s->wLongsPerEntry = sizeof(avisuperindex_entry)/4;
237 } 236 }
238 msize = sizeof (avisuperindex_entry) * s->nEntriesInUse; 237 s->aIndex = calloc(s->nEntriesInUse, sizeof (avisuperindex_entry));
239 s->aIndex = malloc(msize); 238 s->stdidx = calloc(s->nEntriesInUse, sizeof (avistdindex_chunk));
240 memset (s->aIndex, 0, msize);
241 s->stdidx = malloc (s->nEntriesInUse * sizeof (avistdindex_chunk));
242 memset (s->stdidx, 0, s->nEntriesInUse * sizeof (avistdindex_chunk));
243 239
244 // now the real index of indices 240 // now the real index of indices
245 for (i=0; i<s->nEntriesInUse; i++) { 241 for (i=0; i<s->nEntriesInUse; i++) {
246 chunksize-=16; 242 chunksize-=16;
247 s->aIndex[i].qwOffset = stream_read_dword_le(demuxer->stream) & 0xffffffff; 243 s->aIndex[i].qwOffset = stream_read_dword_le(demuxer->stream) & 0xffffffff;