Fix possible UB shift in bs_write_u() for large values of n

This commit is contained in:
Cameron Gutman committed 2026-10-14 01:51:15 -05:00
1 parent ee557e83c6
commit 289782c6f3
1 file changed
+1 -1
+1 -1
View File
@@ -208,7 +208,7 @@ static inline void bs_write_u(bs_t* b, int n, uint32_t v)
int i; int i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
bs_write_u1(b, (v >> ( n - i - 1 ))&0x01 ); bs_write_u1(b, (n - i - 1 >= 32) ? 0 : ((v >> ( n - i - 1 ))&0x01) );
} }
} }