Skip to content

Commit 95d4ff6

Browse files
authoredJan 7, 2019
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)
1 parent 07c1c72 commit 95d4ff6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
 

‎src/client/tile.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -1012,13 +1012,14 @@ video::IImage * Align2Npot2(video::IImage * image,
10121012

10131013
core::dimension2d<u32> dim = image->getDimension();
10141014

1015-
std::string extensions = (char*) glGetString(GL_EXTENSIONS);
1016-
10171015
// Only GLES2 is trusted to correctly report npot support
1018-
if (get_GL_major_version() > 1 &&
1019-
extensions.find("GL_OES_texture_npot") != std::string::npos) {
1016+
// Note: we cache the boolean result. GL context will never change on Android.
1017+
static const bool hasNPotSupport = get_GL_major_version() > 1 &&
1018+
glGetString(GL_EXTENSIONS) &&
1019+
strstr(glGetString(GL_EXTENSIONS), "GL_OES_texture_npot");
1020+
1021+
if (hasNPotSupport)
10201022
return image;
1021-
}
10221023

10231024
unsigned int height = npot2(dim.Height);
10241025
unsigned int width = npot2(dim.Width);

0 commit comments

Comments
 (0)