stszin: add check for allocation error and integer overflow
Fixes (the second part of) #49.
Fabian Greffrath
3 years ago
342 | 342 | u32in(); |
343 | 343 | // Number of entries |
344 | 344 | mp4config.frame.ents = u32in(); |
345 | // fixme error checking | |
346 | 345 | // fixme: check atom size |
347 | 346 | mp4config.frame.data = malloc(sizeof(*mp4config.frame.data) |
348 | 347 | * (mp4config.frame.ents + 1)); |
348 | ||
349 | if (!mp4config.frame.data) | |
350 | return ERR_FAIL; | |
351 | ||
349 | 352 | ofs = 0; |
350 | 353 | mp4config.frame.data[0] = ofs; |
351 | 354 | for (cnt = 0; cnt < mp4config.frame.ents; cnt++) |
357 | 360 | mp4config.frame.maxsize = fsize; |
358 | 361 | |
359 | 362 | mp4config.frame.data[cnt + 1] = ofs; |
363 | ||
364 | if (ofs < mp4config.frame.data[cnt]) | |
365 | return ERR_FAIL; | |
360 | 366 | } |
361 | 367 | |
362 | 368 | return size; |