Skip to content

Commit dbcb66e

Browse files
committed
Fix, IBitView::set() fails with ranges within a single byte.
1 parent 635da8d commit dbcb66e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

libs/basic/bitspan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static void set(void * vdst, size_t dpos, size_t dcnt) {
479479
dpos = dpos % 8;
480480
if (dpos) {
481481
if (dpos + dcnt <= 8) {
482-
auto mask = (unsigned char) (255 << (8 - dcnt) >> dpos);
482+
unsigned char mask = UCHAR_MAX >> (8 - dcnt) << (8 - dpos - dcnt);
483483
apply<Op, unsigned char>(dst, nullptr, mask);
484484
return;
485485
}
@@ -502,7 +502,7 @@ static void set(void * vdst, size_t dpos, size_t dcnt) {
502502
return;
503503
dst += bytes;
504504
}
505-
auto mask = (unsigned char) (255 << (8 - dcnt));
505+
unsigned char mask = UCHAR_MAX << (8 - dcnt);
506506
apply<Op, unsigned char>(dst, nullptr, mask);
507507
}
508508

0 commit comments

Comments
 (0)