mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-10-31 04:58:58 +00:00
Use GPtrArray instead of manually g_realloc
This fixes bug #606791 where the wrong memory was realloced.
This commit is contained in:
parent
6c44cc7889
commit
e373c02658
1 changed files with 9 additions and 7 deletions
|
@ -1613,13 +1613,14 @@ gitg_repository_get_remotes (GitgRepository *repository)
|
||||||
GitgConfig *config = gitg_config_new (repository);
|
GitgConfig *config = gitg_config_new (repository);
|
||||||
gchar *ret = gitg_config_get_value_regex (config, "remote\\..*\\.url");
|
gchar *ret = gitg_config_get_value_regex (config, "remote\\..*\\.url");
|
||||||
|
|
||||||
gchar **remotes = g_malloc (sizeof (gchar *));
|
GPtrArray *remotes = g_ptr_array_new ();
|
||||||
remotes[0] = NULL;
|
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
|
g_ptr_array_add (remotes, NULL);
|
||||||
g_object_unref (config);
|
g_object_unref (config);
|
||||||
return remotes;
|
|
||||||
|
return (gchar **)g_ptr_array_free (remotes, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar **lines = g_strsplit(ret, "\n", -1);
|
gchar **lines = g_strsplit(ret, "\n", -1);
|
||||||
|
@ -1636,17 +1637,18 @@ gitg_repository_get_remotes (GitgRepository *repository)
|
||||||
{
|
{
|
||||||
gchar *name = g_match_info_fetch (info, 1);
|
gchar *name = g_match_info_fetch (info, 1);
|
||||||
|
|
||||||
remotes = g_realloc (ret, sizeof(gchar *) * (++num + 1));
|
g_ptr_array_add (remotes, name);
|
||||||
remotes[num - 1] = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_match_info_free (info);
|
g_match_info_free (info);
|
||||||
++ptr;
|
++ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
remotes[num] = NULL;
|
/* NULL terminate */
|
||||||
|
g_ptr_array_add (remotes, NULL);
|
||||||
g_object_unref (config);
|
g_object_unref (config);
|
||||||
return remotes;
|
|
||||||
|
return (gchar **)g_ptr_array_free (remotes, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|
Loading…
Reference in a new issue