Fix right code in the wrong place.

The recovery stuff was in the wrong if branches; the comments were
correct.

Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
John Bowler 2017-02-21 15:15:48 -08:00
parent 7428ca944d
commit 7218761fe1

View File

@ -59,26 +59,27 @@ int main(int argc, const char **argv)
else
fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
image.message);
free(buffer);
}
else
{
fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
image.message);
/* This is the only place where a 'free' is required; libpng does
* the cleanup on error and success, but in this case we couldn't
* complete the read because of running out of memory.
*/
png_image_free(&image);
}
free(buffer);
}
else
{
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
(unsigned long)PNG_IMAGE_SIZE(image));
/* This is the only place where a 'free' is required; libpng does
* the cleanup on error and success, but in this case we couldn't
* complete the read because of running out of memory and so libpng
* has not got to the point where it can do cleanup.
*/
png_image_free(&image);
}
}
else