klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 566af578b9bf33945bbe397be92427e1386f51b2
parent 9ff76bef82f9fb4dd120f3e74697e9a87af12f52
Author: Oto Havle <havleoto@gmail.com>
Date:   Tue,  8 Nov 2011 14:16:24 +0100

Bugfix: proper error checking in krational_read_decimal

Diffstat:
Msrc/krational.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/krational.c b/src/krational.c @@ -102,7 +102,11 @@ bool krational_read_decimal(klisp_State *K, char *buf, int32_t base, TValue *out /* check to see if there was a decimal point, will only be written to out_decimalp if no error ocurr */ - bool decimalp = memchr(buf, '.', *end - buf) != NULL; + /* TEMP: mp_rat_read_ustring does not set *end if an error occurs. + * Do not let memchr() read past the end of the buffer. */ + bool decimalp = (ret_val == MP_OK || ret_val == MP_TRUNC) + ? (memchr(buf, '.', *end - buf) != NULL) + : false; /* handle exponents, avoid the case where the number finishes in a decimal point (this isn't allowed by kernel */