-
Notifications
You must be signed in to change notification settings - Fork 8
/
10082.diff
30 lines (27 loc) · 1.07 KB
/
10082.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
commit 2dde6c803a9e50c5bff74095187b0cb2e12eebdd
Author: Behdad Esfahbod <[email protected]>
Date: Tue Aug 28 11:02:00 2018 -0700
Explicitly pass reference in hb_auto_t constructor
Fixes clang bots as well as fuzzer issue.
diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index ec5708eb7..8c910748b 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -492,9 +492,16 @@ template <typename Type>
struct hb_auto_t : Type
{
hb_auto_t (void) { Type::init (); }
- template <typename T1> hb_auto_t (T1 t1) { Type::init (t1); }
+ /* Explicitly allow the following only for pointer and references,
+ * to avoid any accidental copies.
+ *
+ * Apparently if we template for all types, then gcc seems to
+ * capture a reference argument in the type, but clang doesn't,
+ * causing unwanted copies and bugs that come with it. */
+ template <typename T1> hb_auto_t (T1 *t1) { Type::init (t1); }
+ template <typename T1> hb_auto_t (T1 &t1) { Type::init (t1); }
~hb_auto_t (void) { Type::fini (); }
private: /* Hide */
void init (void) {}
void fini (void) {}
};