Skip to content

Commit d324fb8

Browse files
committed
Fix bitset copy assignment operator to not run off end of array.
If using a bitset with an even number of bytes, for example bitset<16>, the original code tried to copy 3 bytes instead of 2 and would run off the end of the array.
1 parent 7411816 commit d324fb8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/bitset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ namespace std{
299299
if(&rhs == this){
300300
return *this;
301301
}
302-
for(size_t i = 0; i <= byte_num(N); ++i){
302+
for(size_t i = 0; i < num_bytes; ++i){
303303
data[i] = rhs.data[i];
304304
}
305305
return *this;

0 commit comments

Comments
 (0)