[devel] Initialize row_pointers to NULL with a loop

instead of memset to zero in png_read_png().
This commit is contained in:
Glenn Randers-Pehrson
2009-08-31 10:52:38 -05:00
parent 0af5378d4d
commit d9f21ee796
3 changed files with 10 additions and 7 deletions

View File

@@ -1317,16 +1317,15 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
if (info_ptr->row_pointers == NULL)
{
#ifdef PNG_CALLOC_SUPPORTED
info_ptr->row_pointers = (png_bytepp)png_calloc(png_ptr,
info_ptr->height * png_sizeof(png_bytep));
#else
png_uint_32 iptr;
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
info_ptr->height * png_sizeof(png_bytep));
png_memset(info_ptr->row_pointers, 0, info_ptr->height
* png_sizeof(png_bytep));
#endif
for (iptr=0; iptr<info_ptr->height; iptr++)
info_ptr->row_pointers[iptr] = NULL;
info_ptr->free_me |= PNG_FREE_ROWS;
for (row = 0; row < (int)info_ptr->height; row++)
info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr));