1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

LibGfx: Put debug output in PNGLoader behind PNG_DEBUG

This commit is contained in:
Nico Weber 2020-11-29 14:28:40 -05:00 committed by Andreas Kling
parent d0636291fe
commit 7db765bb73

View file

@ -599,7 +599,9 @@ static bool decode_png_bitmap_simple(PNGLoadingContext& context)
} }
if (filter > 4) { if (filter > 4) {
#ifdef PNG_DEBUG
dbg() << "Invalid PNG filter: " << filter; dbg() << "Invalid PNG filter: " << filter;
#endif
context.state = PNGLoadingContext::State::Error; context.state = PNGLoadingContext::State::Error;
return false; return false;
} }
@ -695,7 +697,9 @@ static bool decode_adam7_pass(PNGLoadingContext& context, Streamer& streamer, in
} }
if (filter > 4) { if (filter > 4) {
#ifdef PNG_DEBUG
dbg() << "Invalid PNG filter: " << filter; dbg() << "Invalid PNG filter: " << filter;
#endif
context.state = PNGLoadingContext::State::Error; context.state = PNGLoadingContext::State::Error;
return false; return false;
} }
@ -832,7 +836,9 @@ static bool process_IHDR(const ByteBuffer& data, PNGLoadingContext& context)
#endif #endif
if (context.interlace_method != PngInterlaceMethod::Null && context.interlace_method != PngInterlaceMethod::Adam7) { if (context.interlace_method != PngInterlaceMethod::Null && context.interlace_method != PngInterlaceMethod::Adam7) {
#ifdef PNG_DEBUG
dbgprintf("PNGLoader::process_IHDR: unknown interlace method: %d\n", context.interlace_method); dbgprintf("PNGLoader::process_IHDR: unknown interlace method: %d\n", context.interlace_method);
#endif
return false; return false;
} }
@ -884,23 +890,31 @@ static bool process_chunk(Streamer& streamer, PNGLoadingContext& context)
{ {
u32 chunk_size; u32 chunk_size;
if (!streamer.read(chunk_size)) { if (!streamer.read(chunk_size)) {
#ifdef PNG_DEBUG
printf("Bail at chunk_size\n"); printf("Bail at chunk_size\n");
#endif
return false; return false;
} }
u8 chunk_type[5]; u8 chunk_type[5];
chunk_type[4] = '\0'; chunk_type[4] = '\0';
if (!streamer.read_bytes(chunk_type, 4)) { if (!streamer.read_bytes(chunk_type, 4)) {
#ifdef PNG_DEBUG
printf("Bail at chunk_type\n"); printf("Bail at chunk_type\n");
#endif
return false; return false;
} }
ByteBuffer chunk_data; ByteBuffer chunk_data;
if (!streamer.wrap_bytes(chunk_data, chunk_size)) { if (!streamer.wrap_bytes(chunk_data, chunk_size)) {
#ifdef PNG_DEBUG
printf("Bail at chunk_data\n"); printf("Bail at chunk_data\n");
#endif
return false; return false;
} }
u32 chunk_crc; u32 chunk_crc;
if (!streamer.read(chunk_crc)) { if (!streamer.read(chunk_crc)) {
#ifdef PNG_DEBUG
printf("Bail at chunk_crc\n"); printf("Bail at chunk_crc\n");
#endif
return false; return false;
} }
#ifdef PNG_DEBUG #ifdef PNG_DEBUG