From 2b2824b9eaa994cb500955fbe2c5a8ea5f85b638 Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Tue, 27 Dec 2022 16:55:58 +0100 Subject: [PATCH] util/xmlconfig: fix memory leak triggered by duplicates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change copies the string once. Direct leak of 196 byte(s) in 14 object(s) allocated from: #0 0x7f71598ec7a7 in strdup (/usr/lib64/libasan.so.6+0x5c7a7) #1 0x7f70a56ff942 in driParseOptionInfo ../src/util/xmlconfig.c:357 #2 0x7f70a56f0565 in pipe_loader_load_options ../src/gallium/auxiliary/pipe-loader/pipe_loader.c:126 #3 0x7f70a56f0565 in pipe_loader_create_screen_vk ../src/gallium/auxiliary/pipe-loader/pipe_loader.c:167 Signed-off-by: Patrick Lerda Reviewed-by: Marek Olšák Part-of: --- src/util/xmlconfig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c index 855b869d8b1..25f90d41786 100644 --- a/src/util/xmlconfig.c +++ b/src/util/xmlconfig.c @@ -350,11 +350,12 @@ driParseOptionInfo(driOptionCache *info, if (optinfo->name) { /* Duplicate options override the value, but the type must match. */ assert(optinfo->type == opt->info.type); + } else { + XSTRDUP(optinfo->name, name); } optinfo->type = opt->info.type; optinfo->range = opt->info.range; - XSTRDUP(optinfo->name, name); switch (opt->info.type) { case DRI_BOOL: