From b7be59311f27112791e9b9c6356464e1c3ff92c1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 16 May 2019 13:32:56 -0700 Subject: [PATCH] Fix msan issue The fact that HB_AUTO_RETURN will return rvalue-references for rvalues is very disturbing. Even apart from that, I'm totally lost re any hb_move needs or hb_forward'ing to functions/templates where the type is fixed by explicitly specifying template parameters. ==1==ERROR: AddressSanitizer: stack-use-after-return on address 0x7f6ad65e51e0 at pc 0x0000005da240 bp 0x7ffc104ab670 sp 0x7ffc104ab668 READ of size 4 at 0x7f6ad65e51e0 thread T0 SCARINESS: 55 (4-byte-read-stack-use-after-return) #0 0x5da23f in bool OT::Coverage::serialize, OT::SingleSubstFormat1::subset(hb_subset_context_t*) const::'lambda'(unsigned int), (hb_function_sortedness_t)1, (void*)0>, $_20&, (hb_function_sortedness_t)1, (void*)0>, (void*)0>(hb_serialize_context_t*, hb_map_iter_t, OT::SingleSubstFormat1::subset(hb_subset_context_t*) const::'lambda'(unsigned int), (hb_function_sortedness_t)1, (void*)0>, $_20&, (hb_function_sortedness_t)1, (void*)0>) harfbuzz/src/hb-ot-layout-common.hh:1055:16 #1 0x5d88f9 in bool OT::SingleSubstFormat1::serialize, OT::SingleSubstFormat1::subset(hb_subset_context_t*) const::'lambda'(unsigned int), (hb_function_sortedness_t)1, (void*)0>, $_20&, (hb_function_sortedness_t)1, (void*)0>, (void*)0>(hb_serialize_context_t*, hb_map_iter_t, OT::SingleSubstFormat1::subset(hb_subset_context_t*) const::'lambda'(unsigned int), (hb_function_sortedness_t)1, (void*)0>, $_20&, (hb_function_sortedness_t)1, (void*)0>, unsigned int) harfbuzz/src/hb-ot-layout-gsub-table.hh:98:9 --- src/hb-algs.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 523629aab..ad756a64a 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -286,15 +286,15 @@ hb_pair (T1&& a, T2&& b) { return hb_pair_t (a, b); } struct { - template auto - operator () (const Pair& pair) const HB_AUTO_RETURN (pair.first) + template typename Pair::first_t + operator () (const Pair& pair) const { return pair.first; } } HB_FUNCOBJ (hb_first); struct { - template auto - operator () (const Pair& pair) const HB_AUTO_RETURN (pair.second) + template typename Pair::second_t + operator () (const Pair& pair) const { return pair.second; } } HB_FUNCOBJ (hb_second);