From 6cf4142db88796ff66a73a36530467101533fdb6 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 3 Sep 2015 15:20:04 +0300 Subject: [PATCH] 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 --- src/mesa/drivers/dri/common/utils.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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; + } + } } } -- 2.30.2