Skip to content

Commit

Permalink
aspl: fix ASPL_LIST_LITERAL allocating too little memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Wertzui123 committed Aug 3, 2024
1 parent 63ca829 commit ad07301
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/aspl/compiler/backend/stringcode/c/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ ASPL_OBJECT_TYPE ASPL_LIST_LITERAL(char* typePtr, int typeLen, ASPL_OBJECT_TYPE
l->length = size;
l->capacity = size;
if (l->capacity < 1) l->capacity = 1; // malloc can return a null pointer if size is 0, but e.g. memcpy can't handle null pointers (even if the size is 0)
l->value = ASPL_MALLOC(l->capacity);
l->value = ASPL_MALLOC(sizeof(ASPL_OBJECT_TYPE) * l->capacity);
memcpy(l->value, list, sizeof(ASPL_OBJECT_TYPE) * size);
ASPL_ACCESS(obj).value.list = l;
return obj;
Expand Down

0 comments on commit ad07301

Please sign in to comment.