2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2018 The Qt Company Ltd.
|
2024-02-22 14:51:16 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2018-11-12 13:27:00 +00:00
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QJSEngine>
|
|
|
|
|
|
|
|
// libfuzzer test for QJSEngine::evaluate()
|
|
|
|
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
|
2019-11-12 10:26:39 +00:00
|
|
|
const QByteArray ba = QByteArray::fromRawData(Data, Size);
|
2018-11-12 13:27:00 +00:00
|
|
|
// avoid potential endless loops
|
|
|
|
if (ba.contains("for") || ba.contains("while"))
|
|
|
|
return 1;
|
|
|
|
int c = 0;
|
|
|
|
QCoreApplication a(c, nullptr);
|
|
|
|
QJSEngine().evaluate(ba);
|
|
|
|
return 0;
|
|
|
|
}
|