aboutsummaryrefslogtreecommitdiff
path: root/util/cutils.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-11-02 13:19:53 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2020-11-03 09:42:52 -0500
commit090afdc5e61e80de4ac158fa4cb2a578ee69be54 (patch)
tree0aca2491db5e21ae98dcac2fcf6c4a3e23634e1f /util/cutils.c
parent83851c7c60c90e9fb6a23ff48076387a77bc33cd (diff)
downloadqemu-090afdc5e61e80de4ac158fa4cb2a578ee69be54.zip
qemu-090afdc5e61e80de4ac158fa4cb2a578ee69be54.tar.gz
qemu-090afdc5e61e80de4ac158fa4cb2a578ee69be54.tar.bz2
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 <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util/cutils.c')
-rw-r--r--util/cutils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util/cutils.c b/util/cutils.c
index c395974..9498e28 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);