]> granicus.if.org Git - php/commitdiff
Fix string offset signed int UB in jit as well
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 20 Dec 2019 11:11:07 +0000 (12:11 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 20 Dec 2019 11:11:07 +0000 (12:11 +0100)
ext/opcache/jit/zend_jit_helpers.c

index 0efd07c3dce6cdae8e199325b79d63fb1d661006..e2ba36c9eee74391c01e87334cbffae55a2e6951 100644 (file)
@@ -610,7 +610,7 @@ try_string_offset:
                offset = Z_LVAL_P(dim);
        }
 
-       if (UNEXPECTED(Z_STRLEN_P(container) < (size_t)((offset < 0) ? -offset : (offset + 1)))) {
+       if (UNEXPECTED(Z_STRLEN_P(container) < ((offset < 0) ? -(size_t)offset : ((size_t)offset + 1)))) {
                zend_error(E_WARNING, "Uninitialized string offset: " ZEND_LONG_FMT, offset);
                ZVAL_EMPTY_STRING(result);
        } else {
@@ -658,7 +658,7 @@ try_string_offset:
                offset = Z_LVAL_P(dim);
        }
 
-       if (UNEXPECTED(Z_STRLEN_P(container) < (size_t)((offset < 0) ? -offset : (offset + 1)))) {
+       if (UNEXPECTED(Z_STRLEN_P(container) < ((offset < 0) ? -(size_t)offset : ((size_t)offset + 1)))) {
                ZVAL_NULL(result);
        } else {
                zend_uchar c;