]> git.sesse.net Git - ffmpeg/blobdiff - tools/target_dem_fuzzer.c
avcodec/Makefile: Remove obsolete dependency of eatqi dec on rl.o
[ffmpeg] / tools / target_dem_fuzzer.c
index e5c41eea010eecd57a8a3ba3683dfaa8b2cbf467..3c03c8d17c05ffab6673a76b1503e2df9f6d43df 100644 (file)
@@ -88,7 +88,7 @@ static int64_t io_seek(void *opaque, int64_t offset, int whence)
 
 // Ensure we don't loop forever
 const uint32_t maxiteration = 8096;
-const int maxblocks= 100000;
+const int maxblocks= 50000;
 
 static const uint64_t FUZZ_TAG = 0x4741542D5A5A5546ULL;
 
@@ -96,7 +96,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     const uint64_t fuzz_tag = FUZZ_TAG;
     uint32_t it = 0;
     AVFormatContext *avfmt = avformat_alloc_context();
-    AVPacket pkt;
+    AVPacket *pkt;
     char filename[1025] = {0};
     AVIOContext *fuzzed_pb = NULL;
     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)
         io_buffer_size = size;
 
+    pkt = av_packet_alloc();
+    if (!pkt)
+        error("Failed to allocate pkt");
+
     io_buffer = av_malloc(io_buffer_size);
     if (!io_buffer)
         error("Failed to allocate io_buffer");
@@ -182,28 +186,26 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
 
     ret = avformat_open_input(&avfmt, filename, fmt, NULL);
     if (ret < 0) {
-        av_freep(&fuzzed_pb->buffer);
-        av_freep(&fuzzed_pb);
-        avformat_free_context(avfmt);
-        return 0;
+        goto fail;
     }
 
     ret = avformat_find_stream_info(avfmt, NULL);
 
-    av_init_packet(&pkt);
-
     //TODO, test seeking
 
     for(it = 0; it < maxiteration; it++) {
-        ret = av_read_frame(avfmt, &pkt);
+        ret = av_read_frame(avfmt, pkt);
         if (ret < 0)
             break;
-        av_packet_unref(&pkt);
+        av_packet_unref(pkt);
     }
-end:
+
+fail:
+    av_packet_free(&pkt);
     av_freep(&fuzzed_pb->buffer);
     avio_context_free(&fuzzed_pb);
     avformat_close_input(&avfmt);
 
     return 0;
+
 }