Commit 97e7b90
committed
fix: guard against nil chunk in bucket.Get to prevent panic
When cache data is loaded from a corrupted file, map entries may point
to chunk indices that are allocated but nil (beyond the saved chunksLen).
The existing bounds check verified chunkIdx against len(chunks) but did
not verify the chunk itself was non-nil before slicing it, which could
cause a runtime panic instead of being counted as a corruption miss.
Add a nil check for the chunk immediately after retrieval from the
chunks slice, before any slice expressions are evaluated.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent cef9ae9 commit 97e7b90
2 files changed
Lines changed: 38 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
396 | 400 | | |
397 | 401 | | |
398 | | - | |
399 | 402 | | |
400 | 403 | | |
401 | 404 | | |
| |||
404 | 407 | | |
405 | 408 | | |
406 | 409 | | |
407 | | - | |
408 | 410 | | |
409 | 411 | | |
410 | 412 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
222 | 224 | | |
223 | 225 | | |
224 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
225 | 259 | | |
226 | 260 | | |
227 | 261 | | |
| |||
0 commit comments