1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-25 14:43:16 +00:00
Fix bug in janet_table_clone that leaked memory.
This commit is contained in:
Calvin Rose 2019-08-05 17:52:05 -05:00
parent 40eff3e4a3
commit ca5dce5d9f

View File

@ -211,7 +211,10 @@ const JanetKV *janet_table_to_struct(JanetTable *t) {
/* Clone a table. */
JanetTable *janet_table_clone(JanetTable *table) {
JanetTable *newTable = janet_gcalloc(JANET_MEMORY_TABLE, sizeof(JanetTable));
memcpy(newTable, table, sizeof(JanetTable));
newTable->count = table->count;
newTable->capacity = table->capacity;
newTable->deleted = table->deleted;
newTable->proto = table->proto;
newTable->data = malloc(newTable->capacity * sizeof(JanetKV));
if (NULL == newTable->data) {
JANET_OUT_OF_MEMORY;