Skip to content
This repository was archived by the owner on Nov 19, 2022. It is now read-only.

allocate the correct sizes #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/glib_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ g_strndup (const char *str, int n)
static void add_to_vector (gchar ***vector, int size, gchar *token)
{
*vector = *vector == NULL ?
(gchar **) malloc (2 * sizeof (*vector)) :
(gchar **) realloc (*vector, (size + 1) * sizeof (*vector));
(gchar **) malloc (2 * sizeof (**vector)) :
(gchar **) realloc (*vector, (size + 1) * sizeof (**vector));

(*vector)[size - 1] = token;
}

static gchar **make_empty_vector ()
{
gchar **vector = (gchar**)malloc (2 * sizeof (vector));
gchar **vector = (gchar**)malloc (2 * sizeof (*vector));
vector [0] = NULL;

return vector;
Expand Down
2 changes: 1 addition & 1 deletion src/mono-io-portability.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ gchar *mono_portability_find_file (int portability_level, const gchar *pathname,
}


new_components = (gchar **)g_new0 (gchar **, num_components + 1);
new_components = g_new0 (gchar *, num_components + 1);

if (num_components > 1) {
if (strcmp (components[0], "") == 0) {
Expand Down