Improve handling oof corrupted PNG images (resolves openfl/openfl#1999)
This commit is contained in:
@@ -21,9 +21,9 @@ namespace lime {
|
||||
|
||||
ReadBuffer (const unsigned char* data, int length) : data (data), length (length), position (0) {}
|
||||
|
||||
void Read (unsigned char* out, int count) {
|
||||
bool Read (unsigned char* out, int count) {
|
||||
|
||||
if (position >= length) return;
|
||||
if (position >= length) return false;
|
||||
|
||||
if (count > length - position) {
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
char unused; // the first byte gets corrupted when passed to libpng?
|
||||
@@ -57,7 +59,9 @@ namespace lime {
|
||||
static void user_read_data_fn (png_structp png_ptr, png_bytep data, png_size_t length) {
|
||||
|
||||
ReadBuffer* buffer = (ReadBuffer*)png_get_io_ptr (png_ptr);
|
||||
buffer->Read (data, length);
|
||||
if (!buffer->Read (data, length)) {
|
||||
png_error (png_ptr, "Read Error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user