Bug 835325 - Clean up and return from BootAnimation PNG reader when libpng reports an error, r=mwu

This commit is contained in:
Glenn Randers-Pehrson 2013-01-28 14:35:20 -05:00
parent e11eef4753
commit b952bab533

View File

@ -297,8 +297,22 @@ AnimationFrame::ReadPngFrame(int outputFormat)
png_structp pngread = png_create_read_struct(PNG_LIBPNG_VER_STRING,
nullptr, nullptr, nullptr);
if (!pngread)
return;
png_infop pnginfo = png_create_info_struct(pngread);
if (!pnginfo) {
png_destroy_read_struct(&pngread, &pnginfo, nullptr);
return;
}
if (setjmp(png_jmpbuf(pngread))) {
// libpng reported an error and longjumped here. Clean up and return.
png_destroy_read_struct(&pngread, &pnginfo, nullptr);
return;
}
RawReadState state;
state.start = file->GetData();
state.length = file->GetDataSize();
@ -306,8 +320,6 @@ AnimationFrame::ReadPngFrame(int outputFormat)
png_set_read_fn(pngread, &state, RawReader);
setjmp(png_jmpbuf(pngread));
png_read_info(pngread, pnginfo);
width = png_get_image_width(pngread, pnginfo);