mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
tools: Fix string leak
Only allocate the return string when we know we are going to return it. Coverity CID #1292292
This commit is contained in:
parent
1aeb6e691e
commit
e651c43914
1 changed files with 3 additions and 2 deletions
|
@ -29,8 +29,7 @@ _sanitize_argument (gchar * arg)
|
||||||
{
|
{
|
||||||
char *equal_index = strstr (arg, "=");
|
char *equal_index = strstr (arg, "=");
|
||||||
char *space_index = strstr (arg, " ");
|
char *space_index = strstr (arg, " ");
|
||||||
gchar *new_string = g_malloc (sizeof (gchar) * (strlen (arg) + 3));
|
gchar *new_string, *tmp_string;
|
||||||
gchar *tmp_string = new_string;
|
|
||||||
|
|
||||||
if (!space_index)
|
if (!space_index)
|
||||||
return g_strdup (arg);
|
return g_strdup (arg);
|
||||||
|
@ -38,6 +37,8 @@ _sanitize_argument (gchar * arg)
|
||||||
if (!equal_index || equal_index > space_index)
|
if (!equal_index || equal_index > space_index)
|
||||||
return g_strdup_printf ("\"%s\"", arg);
|
return g_strdup_printf ("\"%s\"", arg);
|
||||||
|
|
||||||
|
tmp_string = new_string = g_malloc (sizeof (gchar) * (strlen (arg) + 3));
|
||||||
|
|
||||||
for (; *arg != '\0'; arg++) {
|
for (; *arg != '\0'; arg++) {
|
||||||
*tmp_string = *arg;
|
*tmp_string = *arg;
|
||||||
tmp_string += 1;
|
tmp_string += 1;
|
||||||
|
|
Loading…
Reference in a new issue