Add a NULL check in strtol.
The spec says this is undefined behavior, but it will fix one more problem with #8297 Change-Id: Ibc15f306c92b05019de1050a9eb239ba57b1a91e Reviewed-on: https://review.haiku-os.org/c/haiku/+/3029 Reviewed-by: Axel Dörfler <[email protected]>
This commit is contained in:
committed by
Axel Dörfler
parent
15ba64aaa3
commit
c916010e87
@@ -494,6 +494,12 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
|
|||||||
struct locale_data *current = loc->__locales[LC_NUMERIC];
|
struct locale_data *current = loc->__locales[LC_NUMERIC];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (nptr == NULL)
|
||||||
|
{
|
||||||
|
__set_errno (EINVAL);
|
||||||
|
return NAN;
|
||||||
|
}
|
||||||
|
|
||||||
if (group)
|
if (group)
|
||||||
{
|
{
|
||||||
grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
|
grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM)
|
|||||||
grouping = NULL;
|
grouping = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (base < 0 || base == 1 || base > 36)
|
if (base < 0 || base == 1 || base > 36 || nptr == NULL)
|
||||||
{
|
{
|
||||||
__set_errno (EINVAL);
|
__set_errno (EINVAL);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user