mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-16 16:00:30 +02:00
Add more sanity checks in png_load.
This commit is contained in:
1 parent
116edcb77a
commit
496ebf710a
2 files changed
+21
-5
No files matched your search
@@ -53,6 +53,13 @@ static bool LoadTextureLevels(const uint8_t *data, size_t size, ImageFileType ty
|
||||
if (1 == pngLoadPtr((const unsigned char *)data, size, &width[0], &height[0], &image[0], false)) {
|
||||
*num_levels = 1;
|
||||
*fmt = Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
if (!image[0]) {
|
||||
ELOG("WTF");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
ELOG("PNG load failed");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -89,6 +96,10 @@ bool ManagedTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, Imag
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!image[0]) {
|
||||
Crash();
|
||||
}
|
||||
|
||||
if (num_levels < 0 || num_levels >= 16) {
|
||||
ELOG("Invalid num_levels: %d. Falling back to one. Image: %dx%d", num_levels, width[0], height[0]);
|
||||
num_levels = 1;
|
||||
|
||||
Reference in new issue
Block a user