From efde6e44dbd6d340337a96cfe6d024402c86f6d2 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Fri, 27 Nov 2015 00:11:59 +0100 Subject: [PATCH] Just a safety check in thin3d texture loading --- ext/native/thin3d/thin3d.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/native/thin3d/thin3d.cpp b/ext/native/thin3d/thin3d.cpp index afc465a0c4..fe2a951f08 100644 --- a/ext/native/thin3d/thin3d.cpp +++ b/ext/native/thin3d/thin3d.cpp @@ -207,6 +207,11 @@ bool Thin3DTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, T3DIm return false; } + if (num_levels < 0 || num_levels >= 16) { + ELOG("Invalid num_levels: %d. Falling back to one. Image: %dx%d", num_levels, width, height); + num_levels = 1; + } + Create(LINEAR2D, fmt, width[0], height[0], 1, num_levels); for (int i = 0; i < num_levels; i++) { if (image[i]) {