mirror of https://github.com/xemu-project/xemu.git
test: Use g_strndup instead of plain strndup
Due to memory management rules. See HACKING. Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <dce313b46d294ada8826d34609a3447e@tpw09926dag18e.domain1.systemhost.net> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
17dc579903
commit
348fbd5816
|
@ -767,7 +767,7 @@ static void utf8_string(void)
|
||||||
if (*end == ' ') {
|
if (*end == ' ') {
|
||||||
end++;
|
end++;
|
||||||
}
|
}
|
||||||
in = strndup(tail, end - tail);
|
in = g_strndup(tail, end - tail);
|
||||||
str = from_json_str(in, j, NULL);
|
str = from_json_str(in, j, NULL);
|
||||||
g_assert(!str);
|
g_assert(!str);
|
||||||
g_free(in);
|
g_free(in);
|
||||||
|
|
|
@ -104,9 +104,9 @@ static int get_command_arg_str(const char *name,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end)
|
if (end)
|
||||||
*val = strndup(start, end - start);
|
*val = g_strndup(start, end - start);
|
||||||
else
|
else
|
||||||
*val = strdup(start);
|
*val = g_strdup(start);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,10 +126,10 @@ static int get_command_arg_ull(const char *name,
|
||||||
if (errno || *end) {
|
if (errno || *end) {
|
||||||
fprintf(stderr, "%s (%05d): ERROR: cannot parse %s value %s\n",
|
fprintf(stderr, "%s (%05d): ERROR: cannot parse %s value %s\n",
|
||||||
argv0, gettid(), name, valstr);
|
argv0, gettid(), name, valstr);
|
||||||
free(valstr);
|
g_free(valstr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
free(valstr);
|
g_free(valstr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue