|
Lines 342-352
Link Here
|
| 342 |
|
342 |
|
| 343 |
/* allocate space for the PNG image data */ |
343 |
/* allocate space for the PNG image data */ |
| 344 |
rowbytes = png_get_rowbytes(png_ptr, info_ptr); |
344 |
rowbytes = png_get_rowbytes(png_ptr, info_ptr); |
|
|
345 |
if (overflow2(rowbytes, height)) { |
| 346 |
png_destroy_read_struct (&png_ptr, &info_ptr, NULL); |
| 347 |
return NULL; |
| 348 |
} |
| 345 |
if ((image_data = (png_bytep)gdMalloc(rowbytes*height)) == NULL) { |
349 |
if ((image_data = (png_bytep)gdMalloc(rowbytes*height)) == NULL) { |
| 346 |
fprintf(stderr, "gd-png error: cannot allocate image data\n"); |
350 |
fprintf(stderr, "gd-png error: cannot allocate image data\n"); |
| 347 |
png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
351 |
png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
| 348 |
return NULL; |
352 |
return NULL; |
| 349 |
} |
353 |
} |
|
|
354 |
if (overflow2(height, sizeof (png_bytep))) { |
| 355 |
png_destroy_read_struct (&png_ptr, &info_ptr, NULL); |
| 356 |
gdFree (image_data); |
| 357 |
return NULL; |
| 358 |
} |
| 350 |
if ((row_pointers = (png_bytepp)gdMalloc(height*sizeof(png_bytep))) == NULL) { |
359 |
if ((row_pointers = (png_bytepp)gdMalloc(height*sizeof(png_bytep))) == NULL) { |
| 351 |
fprintf(stderr, "gd-png error: cannot allocate row pointers\n"); |
360 |
fprintf(stderr, "gd-png error: cannot allocate row pointers\n"); |
| 352 |
png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
361 |
png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
|
Lines 577-591
Link Here
|
| 577 |
* interlaced images, but interlacing causes some serious complications. */ |
586 |
* interlaced images, but interlacing causes some serious complications. */ |
| 578 |
if (remap) { |
587 |
if (remap) { |
| 579 |
png_bytep *row_pointers; |
588 |
png_bytep *row_pointers; |
|
|
589 |
if (overflow2(sizeof (png_bytep), height)) { |
| 590 |
return; |
| 591 |
} |
| 580 |
row_pointers = gdMalloc(sizeof(png_bytep) * height); |
592 |
row_pointers = gdMalloc(sizeof(png_bytep) * height); |
| 581 |
if (row_pointers == NULL) { |
593 |
if (row_pointers == NULL) { |
| 582 |
fprintf(stderr, "gd-png error: unable to allocate row_pointers\n"); |
594 |
fprintf(stderr, "gd-png error: unable to allocate row_pointers\n"); |
|
|
595 |
return; |
| 583 |
} |
596 |
} |
| 584 |
for (j = 0; j < height; ++j) { |
597 |
for (j = 0; j < height; ++j) { |
| 585 |
if ((row_pointers[j] = (png_bytep)gdMalloc(width)) == NULL) { |
598 |
if ((row_pointers[j] = (png_bytep)gdMalloc(width)) == NULL) { |
| 586 |
fprintf(stderr, "gd-png error: unable to allocate rows\n"); |
599 |
fprintf(stderr, "gd-png error: unable to allocate rows\n"); |
| 587 |
for (i = 0; i < j; ++i) |
600 |
for (i = 0; i < j; ++i) |
| 588 |
gdFree(row_pointers[i]); |
601 |
gdFree(row_pointers[i]); |
|
|
602 |
gdFree(row_pointers); |
| 589 |
return; |
603 |
return; |
| 590 |
} |
604 |
} |
| 591 |
for (i = 0; i < width; ++i) |
605 |
for (i = 0; i < width; ++i) |