tools/target_enc_fuzzer: Only read pix_fmts if its set

Fixes: null pointer dereference
Fixes: rawvideo encoder

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2024-05-05 03:14:26 +02:00
parent c2918eb88e
commit 24bd01ea65
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64
1 changed files with 6 additions and 4 deletions

View File

@ -130,10 +130,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
flags64 = bytestream2_get_le64(&gbc); flags64 = bytestream2_get_le64(&gbc);
int npixfmts = 0; if (c->p.pix_fmts) {
while (c->p.pix_fmts[npixfmts++] != AV_PIX_FMT_NONE) int npixfmts = 0;
; while (c->p.pix_fmts[npixfmts++] != AV_PIX_FMT_NONE)
ctx->pix_fmt = c->p.pix_fmts[bytestream2_get_byte(&gbc) % npixfmts]; ;
ctx->pix_fmt = c->p.pix_fmts[bytestream2_get_byte(&gbc) % npixfmts];
}
switch (c->p.id) { switch (c->p.id) {
case AV_CODEC_ID_FFV1:{ case AV_CODEC_ID_FFV1:{