Commit 38b46694 authored by Paul Berry's avatar Paul Berry
Browse files

Fix infinite loop in piglit_is_extension_in_string.

If piglit_is_extension_in_string() finds an extension whose name
begins with the name it is searching for, but is not equal to the name
it is searching for (e.g. it is searching for EXT_transform_feedback
but it finds EXT_transform_feedback2), we need it to advance to the
end of the substring it's found before restarting the search,
otherwise it will loop indefinitely.

Prevents a hang when running some transform feedback tests on nVidia's
proprietary Linux driver.
Reviewed-by: Brian Paul's avatarBrian Paul <>
parent bc73fbe6
......@@ -145,15 +145,23 @@ bool piglit_is_extension_in_string(const char *haystack, const char *needle)
if (needle_len == 0)
return false;
while (haystack != NULL) {
while (true) {
const char *const s = strstr(haystack, needle);
if (s != NULL
&& (s[needle_len] == ' ' || s[needle_len] == '\0')) {
if (s == NULL)
return false;
if (s[needle_len] == ' ' || s[needle_len] == '\0') {
return true;
haystack = s;
/* strstr found an extension whose name begins with
* needle, but whose name is not equal to needle.
* Restart the search at s + needle_len so that we
* don't just find the same extension again and go
* into an infinite loop.
haystack = s + needle_len;
return false;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment