Commit d1fed5d
committed
fix: handle match_mask == 0 in NEON ctzll to avoid undefined behavior
When all 16 bytes match the allowed range, match_mask becomes 0 after
the bitwise NOT. Calling __builtin_ctzll(0) is undefined behavior.
The code expects match_len == 16 when all bytes match (so the branch
is skipped and p += 16 continues the loop), but this relied on
ctzll(0) returning 64, which is not guaranteed.
Example panic on macOS ARM64:
thread 44856 panic: passing zero to ctz(), which is not a valid argument
src/llhttp/llhttp.c:2654:21: in llhttp__internal__run
match_len = __builtin_ctzll(match_mask) >> 2;
^
Fix by explicitly checking for match_mask == 0 and setting match_len = 16.1 parent 1c14651 commit d1fed5d
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
249 | 255 | | |
250 | 256 | | |
251 | 257 | | |
| |||
0 commit comments