From c5c13006a1f8e5fb9b28a3c2081e93eb4e5d4c98 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 31 Mar 2021 11:23:46 -0700 Subject: [PATCH] [subset] fix memory leaks found in https://oss-fuzz.com/testcase-detail/5179935334465536 --- src/hb-repacker.hh | 3 ++- src/hb-vector.hh | 5 +++++ ...-minimized-hb-subset-fuzzer-5179935334465536 | Bin 0 -> 50501 bytes 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5179935334465536 diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh index 35e3566e5..295dc6415 100644 --- a/src/hb-repacker.hh +++ b/src/hb-repacker.hh @@ -147,7 +147,8 @@ struct graph_t } vertex_t* v = vertices_.push (); - v->obj = *objects[i]; + if (check_success (!vertices_.in_error ())) + v->obj = *objects[i]; if (!removed_nil) continue; for (unsigned i = 0; i < v->obj.links.length; i++) // Fix indices to account for removed nil object. diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 13517a9c2..17f7d486f 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -177,6 +177,11 @@ struct hb_vector_t Type *push (T&& v) { Type *p = push (); + if (p == &Crap (Type)) + // If push failed to allocate then don't copy v, since this may cause + // the created copy to leak memory since we won't have stored a + // reference to it. + return p; *p = hb_forward (v); return p; } diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5179935334465536 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5179935334465536 new file mode 100644 index 0000000000000000000000000000000000000000..61e7fa1797e37ea487246849be171a1ef0b10075 GIT binary patch literal 50501 zcmeHw33yz^mF}r~Z{J?jYISRA?X8w%ZI-pQS}l2zk!&N&n=G#w;~2}bWXYCfVabXy zU_1=52a_2>AUsHTgdrwj2*dCVS&2oMs2!!TehTmAl1wQvpTx^=5gojP@@iUbiUdkS9(hb{A)m#(0!*9U=_I>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