From fb21cf9f3806845ec3f3da704432a3759618a7b5 Mon Sep 17 00:00:00 2001 From: pcpa Date: Sat, 7 Feb 2015 17:08:43 -0200 Subject: [PATCH] Avoid problems if JIT_INSTR_MAX is miscalculated * lib/jit_size.c: Preventively use at least 144 bytes if JIT_INSTR_MAX is less than it. The logic is not guaranteed to be 100% precise, it is mostly heuristics to allocate a buffer with as close as possible size, but a wrong value may cause code generation to write past the end of the buffer. --- ChangeLog | 9 +++++++++ lib/jit_size.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0a6fa04ce..336bf07c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-02-07 Paulo Andrade + + * lib/jit_size.c: Preventively use at least 144 bytes + if JIT_INSTR_MAX is less than it. The logic is not + guaranteed to be 100% precise, it is mostly heuristics + to allocate a buffer with as close as possible size, + but a wrong value may cause code generation to write + past the end of the buffer. + 2015-02-03 Paulo Andrade * lib/lightning.c: Correct the reason the bug in diff --git a/lib/jit_size.c b/lib/jit_size.c index ae4c633bf..612417e88 100644 --- a/lib/jit_size.c +++ b/lib/jit_size.c @@ -110,7 +110,7 @@ _jit_get_size(jit_state_t *_jit) jit_word_t jit_get_max_instr(void) { - return (JIT_INSTR_MAX); + return (JIT_INSTR_MAX >= 144 ? JIT_INSTR_MAX : 144); } void