am 8fc3540f: Merge "be a bit more defensive when parsing extension strings" into ics-mr1

* commit '8fc3540fdf759ff3bb03b00e81d94d6c4102d530':
  be a bit more defensive when parsing extension strings
This commit is contained in:
Mathias Agopian
2011-11-16 21:00:52 -08:00
committed by Android Git Automerger

View File

@@ -220,15 +220,19 @@ 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;
// NOTE: we could avoid the copy if we had strnstr. if (len) {
const String8 ext(start, len); // NOTE: we could avoid the copy if we had strnstr.
// now go through all implementations and look for this extension const String8 ext(start, len);
for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) { // now go through all implementations and look for this extension
// if we find it, add this extension string to our list for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
// (and don't forget the space) if (disp[i].queryString.extensions) {
const char* match = strstr(disp[i].queryString.extensions, ext.string()); // if we find it, add this extension string to our list
if (match && (match[len] == ' ' || match[len] == 0)) { // (and don't forget the space)
mExtensionString.append(start, len+1); 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. // process the next extension string, and skip the space.