Skip to content

Commit

Permalink
Ensure bytes are zero'd when building bytearrays
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Jan 10, 2024
1 parent 0b516fd commit df4435e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/obj_bytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ KRK_Method(bytearray,__init__) {
self->actual = OBJECT_VAL(krk_newBytes(AS_BYTES(argv[1])->length, AS_BYTES(argv[1])->bytes));
} else if (IS_INTEGER(argv[1])) {
self->actual = OBJECT_VAL(krk_newBytes(AS_INTEGER(argv[1]),NULL));
memset(AS_BYTES(self->actual)->bytes, 0, AS_BYTES(self->actual)->length);
} else {
return krk_runtimeError(vm.exceptions->valueError, "expected bytes");
}
Expand Down

0 comments on commit df4435e

Please sign in to comment.