Skip to content

Commit f73f94f

Browse files
author
Moriyoshi Koizumi
committed
Fixed a signed / unsigned issue.
# imagine the case like "\\\xfe" where walk[1] takes a value that is greater # than 127 in integer...
1 parent 73bae37 commit f73f94f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ext/ereg/ereg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
324324
new_l = strlen(buf) + subs[0].rm_so; /* part before the match */
325325
walk = replace;
326326
while (*walk) {
327-
if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= ((char) re.re_nsub)) {
327+
if ('\\' == *walk && isdigit(walk[1]) && ((unsigned char)walk[1]) - '0' <= re.re_nsub) {
328328
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) {
329329
new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
330330
}

ext/standard/reg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
324324
new_l = strlen(buf) + subs[0].rm_so; /* part before the match */
325325
walk = replace;
326326
while (*walk) {
327-
if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= ((char) re.re_nsub)) {
327+
if ('\\' == *walk && isdigit(walk[1]) && ((unsigned char)walk[1]) - '0' <= re.re_nsub) {
328328
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) {
329329
new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
330330
}

0 commit comments

Comments
 (0)