From: Moriyoshi Koizumi Date: Mon, 24 Feb 2003 16:29:00 +0000 (+0000) Subject: Fixed a signed / unsigned issue. X-Git-Tag: RELEASE_0_5~782 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f73f94f2583875b12e8679bf577e22b1a1cf608f;p=php Fixed a signed / unsigned issue. # imagine the case like "\\\xfe" where walk[1] takes a value that is greater # than 127 in integer... --- diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c index d641cf9cfd..1eb83f0187 100644 --- a/ext/ereg/ereg.c +++ b/ext/ereg/ereg.c @@ -324,7 +324,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha new_l = strlen(buf) + subs[0].rm_so; /* part before the match */ walk = replace; while (*walk) { - if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= ((char) re.re_nsub)) { + if ('\\' == *walk && isdigit(walk[1]) && ((unsigned char)walk[1]) - '0' <= re.re_nsub) { if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) { new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so; } diff --git a/ext/standard/reg.c b/ext/standard/reg.c index d641cf9cfd..1eb83f0187 100644 --- a/ext/standard/reg.c +++ b/ext/standard/reg.c @@ -324,7 +324,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha new_l = strlen(buf) + subs[0].rm_so; /* part before the match */ walk = replace; while (*walk) { - if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= ((char) re.re_nsub)) { + if ('\\' == *walk && isdigit(walk[1]) && ((unsigned char)walk[1]) - '0' <= re.re_nsub) { if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) { new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so; }