diff options
author | vladyslavstartsev <vladyslavstartsev@gmail.com> | 2019-04-30 17:33:04 +0300 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-05-14 15:04:21 +0200 |
commit | a07d422ade48e875740a6733543179e7f67a573e (patch) | |
tree | 8c6e68b23335d831c6ae5a1e203d080cd10bdc59 /ext/bcmath/libbcmath/src | |
parent | 3f19f5112a7be3e4aa7ab1704d25de54645be373 (diff) | |
download | php-git-a07d422ade48e875740a6733543179e7f67a573e.tar.gz |
Warn about non well-formed arguments in bcmath
Co-Authored-By: Nikita Popov <nikita.ppv@googlemail.com>
Co-Authored-By: Christoph M. Becker <cmbecker69@gmx.de>
Diffstat (limited to 'ext/bcmath/libbcmath/src')
-rw-r--r-- | ext/bcmath/libbcmath/src/bcmath.h | 2 | ||||
-rw-r--r-- | ext/bcmath/libbcmath/src/str2num.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/ext/bcmath/libbcmath/src/bcmath.h b/ext/bcmath/libbcmath/src/bcmath.h index cf6f854c52..becba7ec3e 100644 --- a/ext/bcmath/libbcmath/src/bcmath.h +++ b/ext/bcmath/libbcmath/src/bcmath.h @@ -108,7 +108,7 @@ _PROTOTYPE(bc_num bc_copy_num, (bc_num num)); _PROTOTYPE(void bc_init_num, (bc_num *num)); -_PROTOTYPE(void bc_str2num, (bc_num *num, char *str, int scale)); +_PROTOTYPE(int bc_str2num, (bc_num *num, char *str, int scale)); _PROTOTYPE(zend_string *bc_num2str_ex, (bc_num num, int scale)); diff --git a/ext/bcmath/libbcmath/src/str2num.c b/ext/bcmath/libbcmath/src/str2num.c index 0ea37d855f..f2d6a73501 100644 --- a/ext/bcmath/libbcmath/src/str2num.c +++ b/ext/bcmath/libbcmath/src/str2num.c @@ -39,7 +39,7 @@ /* Convert strings to bc numbers. Base 10 only.*/ -void +int bc_str2num (bc_num *num, char *str, int scale) { int digits, strscale; @@ -62,7 +62,7 @@ bc_str2num (bc_num *num, char *str, int scale) if ((*ptr != '\0') || (digits+strscale == 0)) { *num = bc_copy_num (BCG(_zero_)); - return; + return *ptr == '\0'; } /* Adjust numbers and allocate storage and initialize fields. */ @@ -107,4 +107,6 @@ bc_str2num (bc_num *num, char *str, int scale) if (bc_is_zero (*num)) (*num)->n_sign = PLUS; + + return 1; } |