Add a QCoreApplication to QSslCertificate fuzz test

Through the use of QApplicationStatic we need to create
an *Application before instantiating the TLS backends.

Change-Id: I1e72ca349f7fed19cec88328fad446cfbcb4f06c
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
This commit is contained in:
Mårten Nordheim 2025-09-17 17:00:51 +02:00
parent 7e80b36f44
commit 9bcf17de50
1 changed files with 5 additions and 0 deletions

View File

@ -1,6 +1,7 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QCoreApplication>
#include <QSslCertificate>
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
@ -8,6 +9,10 @@ extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
static char quiet[] = "QT_LOGGING_RULES=qt.*=false";
static int pe = putenv(quiet);
Q_UNUSED(pe);
static int argc = 1;
static char arg1[] = "fuzzer";
static char *argv[] = { arg1, nullptr };
static QCoreApplication app(argc, argv);
QSslCertificate ssl(QByteArray::fromRawData(Data, Size), QSsl::Pem);
return 0;
}