From 51894c3cbb7328110b0d4cc21436d49fb0332ab4 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 21 Feb 2023 16:37:30 +0100 Subject: [PATCH] (Config file/libretro-common) config_file_extract_value - don't make it dependent on strldup which pulls in another dependency/source file - instead just unroll strldup for this specific one-time instance --- libretro-common/file/config_file.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 3e0acf9451..7d82a74b8b 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -207,12 +207,13 @@ static char *config_file_strip_comment(char *str) static char *config_file_extract_value(char *line) { + char *dst = NULL; while (ISSPACE((int)*line)) line++; /* Note: From this point on, an empty value * string is valid - and in this case, strldup("", sizeof("")) - * will be returned + * will be returned (see Note 2) * > If we instead return NULL, the the entry * is ignored completely - which means we cannot * track *changes* in entry value */ @@ -254,7 +255,13 @@ static char *config_file_extract_value(char *line) return strdup(value); } - return strldup("", sizeof("")); + /* Note 2: This is an unrolled strldup call + * to avoid an unnecessary dependency - + * call is strldup("", sizeof("")) + **/ + dst = (char*)malloc(sizeof(char*) * 2); + strlcpy(dst, "", 1); + return dst; } /* Move semantics? */