From 090afdc5e61e80de4ac158fa4cb2a578ee69be54 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 2 Nov 2020 13:19:53 -0500 Subject: cutils: replace strdup with g_strdup Memory returned by get_relocated_path must be freed with free or g_free depending on the path that the function took; Coverity takes exception to this practice. The fix lets caller use g_free as is standard in QEMU. While at it, mention the requirements on the caller in the doc comment. Suggested-by: Peter Maydell Signed-off-by: Paolo Bonzini --- util/cutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/cutils.c b/util/cutils.c index c395974fab..9498e28e1a 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -937,7 +937,7 @@ char *get_relocated_path(const char *dir) /* Fail if qemu_init_exec_dir was not called. */ assert(exec_dir[0]); if (!starts_with_prefix(dir) || !starts_with_prefix(bindir)) { - return strdup(dir); + return g_strdup(dir); } result = g_string_new(exec_dir); -- cgit v1.2.3-55-g7522