Skip to content

Commit 47ab60e

Browse files
committed
be a bit more defensive when parsing extension strings
hopefully this will fix a crash in the emulator. Bug: 5624674 Change-Id: I96586e29ea20efd73c4ad50870df5b7368bf3c3b
1 parent 69c17a1 commit 47ab60e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

opengl/libs/EGL/egl_display.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,19 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
220220
if (end) {
221221
// length of the extension string
222222
const size_t len = end - start;
223-
// NOTE: we could avoid the copy if we had strnstr.
224-
const String8 ext(start, len);
225-
// now go through all implementations and look for this extension
226-
for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
227-
// if we find it, add this extension string to our list
228-
// (and don't forget the space)
229-
const char* match = strstr(disp[i].queryString.extensions, ext.string());
230-
if (match && (match[len] == ' ' || match[len] == 0)) {
231-
mExtensionString.append(start, len+1);
223+
if (len) {
224+
// NOTE: we could avoid the copy if we had strnstr.
225+
const String8 ext(start, len);
226+
// now go through all implementations and look for this extension
227+
for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
228+
if (disp[i].queryString.extensions) {
229+
// if we find it, add this extension string to our list
230+
// (and don't forget the space)
231+
const char* match = strstr(disp[i].queryString.extensions, ext.string());
232+
if (match && (match[len] == ' ' || match[len] == 0)) {
233+
mExtensionString.append(start, len+1);
234+
}
235+
}
232236
}
233237
}
234238
// process the next extension string, and skip the space.

0 commit comments

Comments
 (0)