| 107 | } // namespace |
| 108 | |
| 109 | TEST(PngCodecTest, RejectsAbsurdDimensionsBeforeAllocating) { |
| 110 | // A real 2x2 PNG with its IHDR forged to 11000x11000 (121 MP > the 100 MP cap). |
| 111 | // Without the cap the decoder value-initializes a ~240 MB buffer straight from |
| 112 | // these header bytes; the cap must reject up front with a dimension error. |
| 113 | auto small = PJ::test::makeGrayPng(2, 2, 16, std::vector<uint16_t>{0, 1000, 2000, 3000}); |
| 114 | ASSERT_GT(small.size(), 33u); |
| 115 | auto huge = pngWithPatchedDimensions(small, 11000, 11000); |
| 116 | |
| 117 | PJ::PngCodec codec; |
| 118 | auto result = codec.decode(rawBytesFrame(huge)); |
| 119 | ASSERT_FALSE(result.has_value()); |
| 120 | EXPECT_NE(result.error().find("dimension"), std::string::npos) << "got: " << result.error(); |
| 121 | } |
| 122 | |
| 123 | TEST(AutoImageCodecTest, NormalizesMono16PngToRgbGrayscale) { |
| 124 | const std::vector<uint16_t> values = {0, 1000, 2000, 3000}; |
nothing calls this directly
no test coverage detected