Commit 81898928 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Fix invalid nullptr detection due to missing DiscardableMemoryAllocator

Linux requires the presence of a base::DiscardableMemoryAllocator
for some fonts handling.

This initialization code is taken from the gfx_unittest harness
see: ui/gfx/test/run_all_unittests.cc

The fuzzer incorrectly reports them as bugs since a nullptr
is deferenced.

Bug: 1144855
Change-Id: Idfc0888b69fac8a3380659b5469bff0acaa6e806
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2511697
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823571}
parent d399e12d
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/render_text.h" #include "ui/gfx/render_text.h"
#if defined(OS_ANDROID) || defined(OS_LINUX)
#include "base/test/test_discardable_memory_allocator.h"
#endif
namespace { namespace {
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -33,11 +37,19 @@ struct Environment { ...@@ -33,11 +37,19 @@ struct Environment {
TestTimeouts::Initialize(), TestTimeouts::Initialize(),
base::test::TaskEnvironment::MainThreadType::UI)) { base::test::TaskEnvironment::MainThreadType::UI)) {
logging::SetMinLogLevel(logging::LOG_FATAL); logging::SetMinLogLevel(logging::LOG_FATAL);
#if defined(OS_ANDROID) || defined(OS_LINUX)
// Some platforms require discardable memory to use bitmap fonts.
base::DiscardableMemoryAllocator::SetInstance(
&discardable_memory_allocator);
#endif
CHECK(base::i18n::InitializeICU()); CHECK(base::i18n::InitializeICU());
gfx::FontList::SetDefaultFontDescription(kFontDescription); gfx::FontList::SetDefaultFontDescription(kFontDescription);
} }
#if defined(OS_ANDROID) || defined(OS_LINUX)
base::TestDiscardableMemoryAllocator discardable_memory_allocator;
#endif
base::AtExitManager at_exit_manager; base::AtExitManager at_exit_manager;
base::test::TaskEnvironment task_environment; base::test::TaskEnvironment task_environment;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment