diff --git a/ext/misc/decimal.c b/ext/misc/decimal.c index a2fab71e49..0d18d00789 100644 --- a/ext/misc/decimal.c +++ b/ext/misc/decimal.c @@ -67,6 +67,9 @@ static void decimal_free(Decimal *p){ /* ** Allocate a new Decimal object initialized to the text in zIn[]. ** Return NULL if any kind of error occurs. +** +** Note that zIn[] is not necessarily zero-terminated. Always +** respect the boundary imposed by the n argument. */ static Decimal *decimalNewFromText(const char *zIn, int n){ Decimal *p = 0; @@ -84,11 +87,11 @@ static Decimal *decimalNewFromText(const char *zIn, int n){ p->nFrac = 0; p->a = sqlite3_malloc64( n+1 ); if( p->a==0 ) goto new_from_text_failed; - for(i=0; IsSpace(zIn[i]); i++){} - if( zIn[i]=='-' ){ + for(i=0; isign = 1; i++; - }else if( zIn[i]=='+' ){ + }else if( i