mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-25 00:32:31 +00:00
tools/target_dem_fuzzer: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
08dbcaa57a
commit
64f092eb5e
@ -96,7 +96,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
const uint64_t fuzz_tag = FUZZ_TAG;
|
const uint64_t fuzz_tag = FUZZ_TAG;
|
||||||
uint32_t it = 0;
|
uint32_t it = 0;
|
||||||
AVFormatContext *avfmt = avformat_alloc_context();
|
AVFormatContext *avfmt = avformat_alloc_context();
|
||||||
AVPacket pkt;
|
AVPacket *pkt;
|
||||||
char filename[1025] = {0};
|
char filename[1025] = {0};
|
||||||
AVIOContext *fuzzed_pb = NULL;
|
AVIOContext *fuzzed_pb = NULL;
|
||||||
uint8_t *io_buffer;
|
uint8_t *io_buffer;
|
||||||
@ -165,6 +165,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
if (!io_buffer_size || size / io_buffer_size > maxblocks)
|
if (!io_buffer_size || size / io_buffer_size > maxblocks)
|
||||||
io_buffer_size = size;
|
io_buffer_size = size;
|
||||||
|
|
||||||
|
pkt = av_packet_alloc();
|
||||||
|
if (!pkt)
|
||||||
|
error("Failed to allocate pkt");
|
||||||
|
|
||||||
io_buffer = av_malloc(io_buffer_size);
|
io_buffer = av_malloc(io_buffer_size);
|
||||||
if (!io_buffer)
|
if (!io_buffer)
|
||||||
error("Failed to allocate io_buffer");
|
error("Failed to allocate io_buffer");
|
||||||
@ -190,17 +194,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
|
|
||||||
ret = avformat_find_stream_info(avfmt, NULL);
|
ret = avformat_find_stream_info(avfmt, NULL);
|
||||||
|
|
||||||
av_init_packet(&pkt);
|
|
||||||
|
|
||||||
//TODO, test seeking
|
//TODO, test seeking
|
||||||
|
|
||||||
for(it = 0; it < maxiteration; it++) {
|
for(it = 0; it < maxiteration; it++) {
|
||||||
ret = av_read_frame(avfmt, &pkt);
|
ret = av_read_frame(avfmt, pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
av_packet_unref(&pkt);
|
av_packet_unref(pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_packet_free(&pkt);
|
||||||
av_freep(&fuzzed_pb->buffer);
|
av_freep(&fuzzed_pb->buffer);
|
||||||
avio_context_free(&fuzzed_pb);
|
avio_context_free(&fuzzed_pb);
|
||||||
avformat_close_input(&avfmt);
|
avformat_close_input(&avfmt);
|
||||||
|
Loading…
Reference in New Issue
Block a user