1
0
mirror of https://github.com/golang/go synced 2024-11-15 05:50:37 -07:00

image/png: remove go-fuzz test

An identical go1.18 test exists at `src/image/png/fuzz_test.go`.

Change-Id: I3e4db46296fb6a56655f849da8c0689aa5a1c28c
Reviewed-on: https://go-review.googlesource.com/c/go/+/576795
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Jorropo 2024-04-05 07:38:52 +02:00 committed by Nigel Tao
parent e988d6c423
commit ad10fbd3c4

View File

@ -1,52 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build gofuzz
package png
import (
"bytes"
"fmt"
)
func Fuzz(data []byte) int {
cfg, err := DecodeConfig(bytes.NewReader(data))
if err != nil {
return 0
}
if cfg.Width*cfg.Height > 1e6 {
return 0
}
img, err := Decode(bytes.NewReader(data))
if err != nil {
return 0
}
levels := []CompressionLevel{
DefaultCompression,
NoCompression,
BestSpeed,
BestCompression,
}
for _, l := range levels {
var w bytes.Buffer
e := &Encoder{CompressionLevel: l}
err = e.Encode(&w, img)
if err != nil {
panic(err)
}
img1, err := Decode(&w)
if err != nil {
panic(err)
}
got := img1.Bounds()
want := img.Bounds()
if !got.Eq(want) {
fmt.Printf("bounds0: %#v\n", want)
fmt.Printf("bounds1: %#v\n", got)
panic("bounds have changed")
}
}
return 1
}