File indexing completed on 2024-04-28 08:43:07

0001 /*
0002     SPDX-FileCopyrightText: 2019 Nicolas Carion
0003     This file is part of Kdenlive. See www.kdenlive.org.
0004 
0005     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #include "core.h"
0009 #include "fuzzing.hpp"
0010 #include <QApplication>
0011 #include <cstring>
0012 #include <iostream>
0013 #include <mlt++/MltFactory.h>
0014 #include <mlt++/MltRepository.h>
0015 
0016 int argc = 1;
0017 char *argv[1] = {"fuzz"};
0018 QApplication app(argc, argv);
0019 std::unique_ptr<Mlt::Repository> repo(Mlt::Factory::init(nullptr));
0020 
0021 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
0022 {
0023     qputenv("MLT_TESTS", QByteArray("1"));
0024     Core::build(false);
0025     const char *input = reinterpret_cast<const char *>(data);
0026     char *target = new char[size + 1];
0027     strncpy(target, input, size);
0028     target[size] = '\0';
0029     std::string str(target);
0030     // std::cout<<"Testcase "<<str<<std::endl;
0031     fuzz(std::string(str));
0032     delete[] target;
0033     return 0;
0034 }