Skip to content

Commit

Permalink
Initialize the memory used for bytearrays
Browse files Browse the repository at this point in the history
We were accessing uninitialized memory whenever using bytearrays which causes valgrind to complain.
Now that memory is just initialized to 0
  • Loading branch information
mattisboeckle committed Jan 22, 2025
1 parent 3b09162 commit 0a13886
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions libraries/llvm/bytearray.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct Pos c_bytearray_new(const Int size) {
void *objPtr = malloc(sizeof(struct Header) + size);
struct Header *headerPtr = objPtr;
*headerPtr = (struct Header) { .rc = 0, .eraser = c_bytearray_erase_noop, };
memset(objPtr + sizeof(struct Header), 0, size);
return (struct Pos) {
.tag = size,
.obj = objPtr,
Expand Down

0 comments on commit 0a13886

Please sign in to comment.