From: Denis Pronin Date: Sun, 10 Apr 2022 12:41:47 +0000 (+0300) Subject: fixed bunch of memory leaks in json constructor X-Git-Tag: test-tag-2022-08-09~62^2~1 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=e0825685ecf76988683488390096890114478aab;p=fio.git fixed bunch of memory leaks in json constructor fixed memory leak produced by not freed string given by 'strdup' in 'json_object_add_value_string' function Signed-off-by: Denis Pronin --- diff --git a/json.h b/json.h index d9824263..66bb06b1 100644 --- a/json.h +++ b/json.h @@ -81,8 +81,13 @@ static inline int json_object_add_value_string(struct json_object *obj, struct json_value arg = { .type = JSON_TYPE_STRING, }; + union { + const char *a; + char *b; + } string; - arg.string = strdup(val ? : ""); + string.a = val ? val : ""; + arg.string = string.b; return json_object_add_value_type(obj, name, &arg); }