Use strlen() rather than fixed length in fast_atof.h
This avoids reading past the length of the input string.pull/4016/head
parent
8f02c29023
commit
538cb3125c
|
@ -194,7 +194,7 @@ uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_ino
|
||||||
|
|
||||||
if ( *in < '0' || *in > '9' ) {
|
if ( *in < '0' || *in > '9' ) {
|
||||||
// The string is known to be bad, so don't risk printing the whole thing.
|
// The string is known to be bad, so don't risk printing the whole thing.
|
||||||
throw ExceptionType("The string \"", ai_str_toprintable(in, 30), "\" cannot be converted into a value." );
|
throw ExceptionType("The string \"", ai_str_toprintable(in, (int)strlen(in)), "\" cannot be converted into a value." );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
|
@ -294,7 +294,7 @@ const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true)
|
||||||
if (!(c[0] >= '0' && c[0] <= '9') &&
|
if (!(c[0] >= '0' && c[0] <= '9') &&
|
||||||
!((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')) {
|
!((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')) {
|
||||||
// The string is known to be bad, so don't risk printing the whole thing.
|
// The string is known to be bad, so don't risk printing the whole thing.
|
||||||
throw ExceptionType("Cannot parse string \"", ai_str_toprintable(c, 30),
|
throw ExceptionType("Cannot parse string \"", ai_str_toprintable(c, (int)strlen(c)),
|
||||||
"\" as a real number: does not start with digit "
|
"\" as a real number: does not start with digit "
|
||||||
"or decimal point followed by digit.");
|
"or decimal point followed by digit.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue