fuzzFseEncoder can be used to fuzz the FSE encoder.
(data []byte)
| 441 | |
| 442 | // fuzzFseEncoder can be used to fuzz the FSE encoder. |
| 443 | func fuzzFseEncoder(data []byte) int { |
| 444 | if len(data) > maxSequences || len(data) < 2 { |
| 445 | return 0 |
| 446 | } |
| 447 | enc := fseEncoder{} |
| 448 | hist := enc.Histogram() |
| 449 | maxSym := uint8(0) |
| 450 | for i, v := range data { |
| 451 | v = v & 63 |
| 452 | data[i] = v |
| 453 | hist[v]++ |
| 454 | if v > maxSym { |
| 455 | maxSym = v |
| 456 | } |
| 457 | } |
| 458 | if maxSym == 0 { |
| 459 | // All 0 |
| 460 | return 0 |
| 461 | } |
| 462 | cnt := int(slices.Max(hist[:maxSym])) |
| 463 | if cnt == len(data) { |
| 464 | // RLE |
| 465 | return 0 |
| 466 | } |
| 467 | enc.HistogramFinished(maxSym, cnt) |
| 468 | err := enc.normalizeCount(len(data)) |
| 469 | if err != nil { |
| 470 | return 0 |
| 471 | } |
| 472 | _, err = enc.writeCount(nil) |
| 473 | if err != nil { |
| 474 | panic(err) |
| 475 | } |
| 476 | return 1 |
| 477 | } |
| 478 | |
| 479 | // encode will encode the block and append the output in b.output. |
| 480 | // Previous offset codes must be pushed if more blocks are expected. |
nothing calls this directly
no test coverage detected
searching dependent graphs…