forked from Mirrorlandia_minetest/minetest
Fix a crash on Android with Align2Npot2 (#8070)
* Fix a crash on Android with Align2Npot2 glGetString can be NULL. If stored in a string it triggers a SIGSEGV. Instead do a basic strstr and verify the pointer * Better Align2Npot2 check (+ performance)
This commit is contained in:
parent
dda844be16
commit
426b5d3149
@ -1138,13 +1138,14 @@ video::IImage * Align2Npot2(video::IImage * image,
|
|||||||
|
|
||||||
core::dimension2d<u32> dim = image->getDimension();
|
core::dimension2d<u32> dim = image->getDimension();
|
||||||
|
|
||||||
std::string extensions = (char*) glGetString(GL_EXTENSIONS);
|
|
||||||
|
|
||||||
// Only GLES2 is trusted to correctly report npot support
|
// Only GLES2 is trusted to correctly report npot support
|
||||||
if (get_GL_major_version() > 1 &&
|
// Note: we cache the boolean result. GL context will never change on Android.
|
||||||
extensions.find("GL_OES_texture_npot") != std::string::npos) {
|
static const bool hasNPotSupport = get_GL_major_version() > 1 &&
|
||||||
|
glGetString(GL_EXTENSIONS) &&
|
||||||
|
strstr(glGetString(GL_EXTENSIONS), "GL_OES_texture_npot");
|
||||||
|
|
||||||
|
if (hasNPotSupport)
|
||||||
return image;
|
return image;
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int height = npot2(dim.Height);
|
unsigned int height = npot2(dim.Height);
|
||||||
unsigned int width = npot2(dim.Width);
|
unsigned int width = npot2(dim.Width);
|
||||||
|
Loading…
Reference in New Issue
Block a user