Commit 1aee94e
committed
Address PR nats-io#7871 review feedback: fix batch compression bugs
Apply feedback from Claude and Codex reviewers:
1. Fix critical bug: compressed length comparison `len(ebuf) < len(buf)`
did not account for batch prefix offset. For batched messages where
opIndex > 0, the comparison must be against the payload window size
`len(buf)-opIndex-1` to avoid data truncation or corruption.
2. Fix heap escape in putCompressBuf: taking `&buf` of a slice parameter
causes the slice header to escape to heap on every call. Instead,
return the pool pointer from getCompressBuf and pass it back to
putCompressBuf directly.
3. Remove dead code: `nbuf[0] = byte(compressedStreamMsgOp)` was never
used since the op byte is written into buf, not nbuf.
https://claude.ai/code/session_01LU1gqVBKHyaQdkJ6K9Ur351 parent fb8f1ae commit 1aee94e
1 file changed
+12
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9397 | 9397 | | |
9398 | 9398 | | |
9399 | 9399 | | |
9400 | | - | |
| 9400 | + | |
9401 | 9401 | | |
9402 | 9402 | | |
9403 | 9403 | | |
9404 | | - | |
| 9404 | + | |
9405 | 9405 | | |
9406 | 9406 | | |
9407 | 9407 | | |
9408 | | - | |
| 9408 | + | |
| 9409 | + | |
9409 | 9410 | | |
9410 | 9411 | | |
9411 | | - | |
9412 | | - | |
| 9412 | + | |
| 9413 | + | |
9413 | 9414 | | |
9414 | 9415 | | |
9415 | 9416 | | |
| |||
9468 | 9469 | | |
9469 | 9470 | | |
9470 | 9471 | | |
9471 | | - | |
9472 | | - | |
9473 | | - | |
| 9472 | + | |
| 9473 | + | |
9474 | 9474 | | |
9475 | 9475 | | |
9476 | | - | |
| 9476 | + | |
| 9477 | + | |
| 9478 | + | |
9477 | 9479 | | |
9478 | 9480 | | |
9479 | 9481 | | |
9480 | 9482 | | |
9481 | | - | |
| 9483 | + | |
9482 | 9484 | | |
9483 | 9485 | | |
9484 | 9486 | | |
| |||
0 commit comments