office-gobmx/vcl/workben/jpgfuzzer.cxx
Miklos Vajna e8a05109d9 vcl: split jpeg import into two parts
Split the import into two:

1) Just create the bitmap, this part is not thread-safe (e.g.
OpenGLContext::makeCurrent() is called when OpenGL is enabled).

2) Import the image into an existing bitmap.

The point is that the second part takes much more time than the first,
and in the future that part may be executed on a thread, while without
such a split the whole ImportJPEG() can't do that. For now
GraphicFilter::ImportGraphic() simply invokes the two parts after each
other, so no real functional changes yet.

Change-Id: Iee742a2cd3c581aeaf1a1ed9f55cd543955a85e0
Reviewed-on: https://gerrit.libreoffice.org/37397
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2017-05-08 19:20:40 +02:00

28 lines
889 B
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <tools/stream.hxx>
#include <../source/filter/jpeg/jpeg.hxx>
#include "commonfuzzer.hxx"
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
{
TypicalFuzzerInitialize(argc, argv);
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
Graphic aGraphic;
(void)ImportJPEG(aStream, aGraphic, GraphicFilterImportFlags::NONE, nullptr);
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */