diff --git a/libs/gamecode/engine/pr_builtins.c b/libs/gamecode/engine/pr_builtins.c index 7230f69c0..742a30095 100644 --- a/libs/gamecode/engine/pr_builtins.c +++ b/libs/gamecode/engine/pr_builtins.c @@ -93,6 +93,7 @@ void PR_RegisterBuiltins (progs_t *pr, builtin_t *builtins) { builtin_t *bi; + int count; if (!pr->builtin_hash) { pr->builtin_hash = Hash_NewTable (1021, builtin_get_key, 0, pr); @@ -101,6 +102,13 @@ PR_RegisterBuiltins (progs_t *pr, builtin_t *builtins) builtin_compare); } + // count = 1 for terminator + for (bi = builtins, count = 1; bi->name; bi++) + count++; + bi = malloc (count * sizeof (builtin_t)); + memcpy (bi, builtins, count * sizeof (builtin_t)); + builtins = bi; + while (builtins->name) { if (builtins->binum == 0 || builtins->binum >= PR_AUTOBUILTIN) PR_Error (pr, "bad builtin number: %s = #%d", builtins->name,