From 642135f3b2d6d6eb800153c76c4718239733c0e6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 3 Nov 2015 11:26:34 -0800 Subject: [PATCH] [util] In --debug mode, duplicate font data This has the effect that the font data will end up in a memory section malloc()ed exactly to its size. This gives us better valgrind detection of out-of-bounds access. Previously, the font data was placed in a mmap()ed section or GString-allocated area, which didn't have proper protections at the end when running under valgrind. --- util/options.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/options.cc b/util/options.cc index 0005f5c60..60f5268cf 100644 --- a/util/options.cc +++ b/util/options.cc @@ -538,6 +538,9 @@ font_options_t::get_font (void) const } } + if (debug) + mm = HB_MEMORY_MODE_DUPLICATE; + blob = hb_blob_create (font_data, len, mm, user_data, destroy); }