@@ -109,7 +109,7 @@ static bool bc_scientific_notation_str2num(
109
109
bc_num * num , const char * str , const char * end , const char * integer_ptr , const char * fractional_ptr , const char * exponent_ptr ,
110
110
size_t digits , size_t * full_scale )
111
111
{
112
- const char * fractional_end = exponent_ptr ;
112
+ const char * fractional_end = fractional_ptr != NULL ? exponent_ptr : NULL ;
113
113
114
114
if (UNEXPECTED (* exponent_ptr != 'e' && * exponent_ptr != 'E' )) {
115
115
goto fail ;
@@ -173,7 +173,9 @@ static bool bc_scientific_notation_str2num(
173
173
}
174
174
175
175
nptr = bc_copy_and_toggle_bcd (nptr , integer_ptr , integer_end );
176
- nptr = bc_copy_and_toggle_bcd (nptr , fractional_ptr , fractional_end );
176
+ if (fractional_ptr != NULL ) {
177
+ nptr = bc_copy_and_toggle_bcd (nptr , fractional_ptr , fractional_end );
178
+ }
177
179
178
180
if (digits > str_full_len ) {
179
181
/* Fill the rest integer part with zeros */
@@ -222,7 +224,7 @@ bool bc_str2num(bc_num *num, const char *str, const char *end, size_t scale, siz
222
224
223
225
/* If a non-digit and non-decimal-point indicator is in the string, i.e. an invalid character */
224
226
if (UNEXPECTED (!decimal_point && * ptr != '\0' )) {
225
- goto fail ;
227
+ return bc_scientific_notation_str2num ( num , str , end , integer_ptr , fractional_ptr , ptr , digits , full_scale ) ;
226
228
}
227
229
228
230
/* search and validate fractional end if exists */
@@ -311,8 +313,4 @@ bool bc_str2num(bc_num *num, const char *str, const char *end, size_t scale, siz
311
313
zero :
312
314
* num = bc_copy_num (BCG (_zero_ ));
313
315
return true;
314
-
315
- fail :
316
- * num = bc_copy_num (BCG (_zero_ ));
317
- return false;
318
316
}
0 commit comments