From d3b984d3790d61931d4427ad7c0ae6547f8f1076 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 2 Sep 2019 18:18:25 +0430 Subject: [PATCH] Revert in-house pow10 (d80a3ea) and fix oss-fuzz/16922 Probably can be fixed but merging it was wrong so let's revert. --- src/hb-cff-interp-dict-common.hh | 37 ++---------------- ...inimized-hb-subset-fuzzer-5728664968232960 | Bin 0 -> 28 bytes 2 files changed, 3 insertions(+), 34 deletions(-) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5728664968232960 diff --git a/src/hb-cff-interp-dict-common.hh b/src/hb-cff-interp-dict-common.hh index 07deef6e2..1d5df2582 100644 --- a/src/hb-cff-interp-dict-common.hh +++ b/src/hb-cff-interp-dict-common.hh @@ -75,37 +75,6 @@ struct top_dict_values_t : dict_values_t unsigned int FDArrayOffset; }; -/* Compile time calculating 10^n for n = 2^i */ -constexpr double -pow10_of_2i (unsigned int n) -{ - return n == 1 ? 10. : pow10_of_2i (n >> 1) * pow10_of_2i (n >> 1); -} - -static const double powers_of_10[] = -{ - pow10_of_2i (0x100), - pow10_of_2i (0x80), - pow10_of_2i (0x40), - pow10_of_2i (0x20), - pow10_of_2i (0x10), - pow10_of_2i (0x8), - pow10_of_2i (0x4), - pow10_of_2i (0x2), - pow10_of_2i (0x1), -}; - -/* Works for x < 512 */ -inline double -_hb_pow10 (unsigned int x) -{ - unsigned int mask = 0x100; /* Should be same with the first element */ - unsigned long result = 1; - const double *power = powers_of_10; - for (; mask; ++power, mask >>= 1) if (mask & x) result *= *power; - return result; -} - struct dict_opset_t : opset_t { static void process_op (op_code_t op, interp_env_t& env) @@ -168,7 +137,7 @@ struct dict_opset_t : opset_t value = (double) (neg ? -int_part : int_part); if (frac_count > 0) { - double frac = frac_part / _hb_pow10 (frac_count); + double frac = frac_part / pow (10.0, (double) frac_count); if (neg) frac = -frac; value += frac; } @@ -184,9 +153,9 @@ struct dict_opset_t : opset_t if (exp_part != 0) { if (exp_neg) - value /= _hb_pow10 (exp_part); + value /= pow (10.0, (double) exp_part); else - value *= _hb_pow10 (exp_part); + value *= pow (10.0, (double) exp_part); } return value; diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5728664968232960 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5728664968232960 new file mode 100644 index 0000000000000000000000000000000000000000..e099413bdc8e3e3227c5ee40fef0a46db91accea GIT binary patch literal 28 icmZQzWME)mRA5qIW8imob2CzqQ^)~|uq*smPyhfSrvr-s literal 0 HcmV?d00001