Skip to content

Commit 5830938

Browse files
committed
Fixed hex char parsing
1 parent fd4b072 commit 5830938

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/ffi/ffi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7445,23 +7445,25 @@ void zend_ffi_val_character(zend_ffi_val *val, const char *str, size_t str_len)
74457445
val->kind = ZEND_FFI_VAL_ERROR;
74467446
}
74477447
} else if (str[2] == 'x') {
7448-
if (str[3] >= '0' && str[3] <= '7') {
7448+
if (str[3] >= '0' && str[3] <= '9') {
74497449
n = str[3] - '0';
74507450
} else if (str[3] >= 'A' && str[3] <= 'F') {
74517451
n = str[3] - 'A';
74527452
} else if (str[3] >= 'a' && str[3] <= 'f') {
74537453
n = str[3] - 'a';
74547454
} else {
74557455
val->kind = ZEND_FFI_VAL_ERROR;
7456+
return;
74567457
}
7457-
if ((str[4] >= '0' && str[4] <= '7') && str_len == 6) {
7458+
if ((str[4] >= '0' && str[4] <= '9') && str_len == 6) {
74587459
n = n * 16 + (str[4] - '0');
74597460
} else if ((str[4] >= 'A' && str[4] <= 'F') && str_len == 6) {
74607461
n = n * 16 + (str[4] - 'A');
74617462
} else if ((str[4] >= 'a' && str[4] <= 'f') && str_len == 6) {
74627463
n = n * 16 + (str[4] - 'a');
74637464
} else if (str_len != 5) {
74647465
val->kind = ZEND_FFI_VAL_ERROR;
7466+
return;
74657467
}
74667468
val->ch = n;
74677469
} else if (str_len == 4) {

0 commit comments

Comments
 (0)