aboutsummaryrefslogtreecommitdiff
path: root/src/client/tile.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2019-01-07 17:05:18 +0100
committerGitHub <noreply@github.com>2019-01-07 17:05:18 +0100
commit95d4ff6d1b62945decc85003a99588bb0539c45b (patch)
treef8658b1ff6fa97926c125b53c86402392728f22b /src/client/tile.cpp
parent07c1c72aae71bd4405ec8e52bfa841b483de7198 (diff)
downloadminetest-95d4ff6d1b62945decc85003a99588bb0539c45b.tar.gz
minetest-95d4ff6d1b62945decc85003a99588bb0539c45b.tar.bz2
minetest-95d4ff6d1b62945decc85003a99588bb0539c45b.zip
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)
Diffstat (limited to 'src/client/tile.cpp')
-rw-r--r--src/client/tile.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/client/tile.cpp b/src/client/tile.cpp
index 019b6e7fa..a65eb5fc8 100644
--- a/src/client/tile.cpp
+++ b/src/client/tile.cpp
@@ -1012,13 +1012,14 @@ video::IImage * Align2Npot2(video::IImage * image,
core::dimension2d<u32> dim = image->getDimension();
- std::string extensions = (char*) glGetString(GL_EXTENSIONS);
-
// Only GLES2 is trusted to correctly report npot support
- if (get_GL_major_version() > 1 &&
- extensions.find("GL_OES_texture_npot") != std::string::npos) {
+ // Note: we cache the boolean result. GL context will never change on Android.
+ static const bool hasNPotSupport = get_GL_major_version() > 1 &&
+ glGetString(GL_EXTENSIONS) &&
+ strstr(glGetString(GL_EXTENSIONS), "GL_OES_texture_npot");
+
+ if (hasNPotSupport)
return image;
- }
unsigned int height = npot2(dim.Height);
unsigned int width = npot2(dim.Width);