From a07d422ade48e875740a6733543179e7f67a573e Mon Sep 17 00:00:00 2001 From: vladyslavstartsev Date: Tue, 30 Apr 2019 17:33:04 +0300 Subject: Warn about non well-formed arguments in bcmath Co-Authored-By: Nikita Popov Co-Authored-By: Christoph M. Becker --- ext/bcmath/libbcmath/src/bcmath.h | 2 +- ext/bcmath/libbcmath/src/str2num.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'ext/bcmath/libbcmath/src') 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; } -- cgit v1.2.1