diff options
author | Mathias Agopian <mathias@google.com> | 2011-11-16 16:49:25 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-11-16 16:49:25 -0800 |
commit | 47ab60e93f56c64a06e42977a8038e341befca25 (patch) | |
tree | 146425a05baa711a5ef69e64c93c98e7a80bb7c9 /opengl | |
parent | 69c17a11a2ce5badc238e66ce9f8ca4a3a1028b3 (diff) | |
download | frameworks_base-47ab60e93f56c64a06e42977a8038e341befca25.zip frameworks_base-47ab60e93f56c64a06e42977a8038e341befca25.tar.gz frameworks_base-47ab60e93f56c64a06e42977a8038e341befca25.tar.bz2 |
be a bit more defensive when parsing extension strings
hopefully this will fix a crash in the emulator.
Bug: 5624674
Change-Id: I96586e29ea20efd73c4ad50870df5b7368bf3c3b
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/libs/EGL/egl_display.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp index 862b48d..31119f9 100644 --- a/opengl/libs/EGL/egl_display.cpp +++ b/opengl/libs/EGL/egl_display.cpp @@ -220,15 +220,19 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { if (end) { // length of the extension string const size_t len = end - start; - // NOTE: we could avoid the copy if we had strnstr. - const String8 ext(start, len); - // now go through all implementations and look for this extension - for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) { - // if we find it, add this extension string to our list - // (and don't forget the space) - const char* match = strstr(disp[i].queryString.extensions, ext.string()); - if (match && (match[len] == ' ' || match[len] == 0)) { - mExtensionString.append(start, len+1); + if (len) { + // NOTE: we could avoid the copy if we had strnstr. + const String8 ext(start, len); + // now go through all implementations and look for this extension + for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) { + if (disp[i].queryString.extensions) { + // if we find it, add this extension string to our list + // (and don't forget the space) + const char* match = strstr(disp[i].queryString.extensions, ext.string()); + if (match && (match[len] == ' ' || match[len] == 0)) { + mExtensionString.append(start, len+1); + } + } } } // process the next extension string, and skip the space. |