Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3ae82d8 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

be a bit more defensive when parsing extension strings

hopefully this will fix a crash in the emulator.

Bug: 5624674
Change-Id: I96586e29ea20efd73c4ad50870df5b7368bf3c3b
parent c554d2b8
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -220,10 +220,12 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
        if (end) {
            // length of the extension string
            const size_t len = end - start;
            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());
@@ -231,6 +233,8 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
                            mExtensionString.append(start, len+1);
                        }
                    }
                }
            }
            // process the next extension string, and skip the space.
            start = end + 1;
        }