util/xmlconfig: fix memory leak triggered by duplicates

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 <patrick9876@free.fr>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20026>
This commit is contained in:
Patrick Lerda 2022-12-27 16:55:58 +01:00 committed by Marge Bot
parent f603d8ce9e
commit 2b2824b9ea

View file

@ -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: