mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 00:27:57 +00:00
grok_infnan: Handle empty input
This public function dereferences its pointer parameter before checking its validity.
This commit is contained in:
parent
cea46623dd
commit
ed5117fa8b
@ -1434,8 +1434,8 @@ Adip |UV |grok_hex |NN const char *start \
|
||||
|NN STRLEN *len_p \
|
||||
|NN I32 *flags \
|
||||
|NULLOK NV *result
|
||||
Adp |int |grok_infnan |NN const char **sp \
|
||||
|NN const char *send
|
||||
Adp |int |grok_infnan |SPTR const char **sp \
|
||||
|EPTRge const char *send
|
||||
Adp |int |grok_number |NN const char *pv \
|
||||
|STRLEN len \
|
||||
|NULLOK UV *valuep
|
||||
|
||||
@ -666,13 +666,18 @@ zero is returned, and C<*sp> will not move.
|
||||
int
|
||||
Perl_grok_infnan(pTHX_ const char** sp, const char* send)
|
||||
{
|
||||
PERL_ARGS_ASSERT_GROK_INFNAN;
|
||||
|
||||
const char* s = *sp;
|
||||
|
||||
if (UNLIKELY(s >= send)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
#if defined(NV_INF) || defined(NV_NAN)
|
||||
bool odh = FALSE; /* one-dot-hash: 1.#INF */
|
||||
|
||||
PERL_ARGS_ASSERT_GROK_INFNAN;
|
||||
|
||||
if (*s == '+') {
|
||||
s++; if (s == send) return 0;
|
||||
}
|
||||
|
||||
2
proto.h
generated
2
proto.h
generated
@ -1259,7 +1259,7 @@ Perl_grok_bin_oct_hex(pTHX_ const char * const start, STRLEN *len_p, I32 *flags,
|
||||
PERL_CALLCONV int
|
||||
Perl_grok_infnan(pTHX_ const char **sp, const char *send);
|
||||
#define PERL_ARGS_ASSERT_GROK_INFNAN \
|
||||
assert(sp); assert(send)
|
||||
assert(sp); assert(*sp); assert(send); assert(*sp <= send)
|
||||
|
||||
PERL_CALLCONV int
|
||||
Perl_grok_number(pTHX_ const char *pv, STRLEN len, UV *valuep);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user