From: Francisco Jerez Date: Thu, 3 Sep 2015 12:20:04 +0000 (+0300) Subject: dri/common: Tokenize driParseDebugString() argument before matching debug flags. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6cf4142db88796ff66a73a36530467101533fdb6;p=mesa.git dri/common: Tokenize driParseDebugString() argument before matching debug flags. Fixes debug string parsing when one of the supported flags is a substring of another. Reviewed-by: Iago Toral Quiroga --- diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c index 1e3b15b6190..1246bec6e02 100644 --- a/src/mesa/drivers/dri/common/utils.c +++ b/src/mesa/drivers/dri/common/utils.c @@ -50,10 +50,19 @@ driParseDebugString(const char *debug, if (debug != NULL) { for (; control->string != NULL; control++) { - if (!strcmp(debug, "all") || - strstr(debug, control->string) != NULL) { - flag |= control->flag; - } + if (!strcmp(debug, "all")) { + flag |= control->flag; + + } else { + const char *s = debug; + unsigned n; + + for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) { + if (strlen(control->string) == n && + !strncmp(control->string, s, n)) + flag |= control->flag; + } + } } }