Merge "be a bit more defensive when parsing extension strings" into ics-mr1

This commit is contained in:
Mathias Agopian 2011-11-16 20:59:30 -08:00 committed by Android (Google) Code Review
commit 410f141622

View File

@ -220,10 +220,12 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
if (end) { if (end) {
// length of the extension string // length of the extension string
const size_t len = end - start; const size_t len = end - start;
if (len) {
// NOTE: we could avoid the copy if we had strnstr. // NOTE: we could avoid the copy if we had strnstr.
const String8 ext(start, len); const String8 ext(start, len);
// now go through all implementations and look for this extension // now go through all implementations and look for this extension
for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) { 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 // if we find it, add this extension string to our list
// (and don't forget the space) // (and don't forget the space)
const char* match = strstr(disp[i].queryString.extensions, ext.string()); const char* match = strstr(disp[i].queryString.extensions, ext.string());
@ -231,6 +233,8 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
mExtensionString.append(start, len+1); mExtensionString.append(start, len+1);
} }
} }
}
}
// process the next extension string, and skip the space. // process the next extension string, and skip the space.
start = end + 1; start = end + 1;
} }