Prevent integer overflow

This commit is contained in:
Přemysl Eric Janouch 2015-02-14 08:54:42 +01:00
parent 4793e93d69
commit 386126ffdb
1 changed files with 3 additions and 0 deletions

View File

@ -828,7 +828,10 @@ load (app_context_t *app)
if (fscanf (fp, "%d %d %zu %zu", &x, &y, &w, &h) != 4)
goto error;
if (w && h > SIZE_MAX / w)
goto error;
size_t size = w * h;
uint8_t *bitmap = calloc (size, sizeof *bitmap);
if (!bitmap)
goto error;