Skip to content
28 changes: 28 additions & 0 deletions Zend/zend_cpuinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,58 +127,86 @@ ZEND_API int zend_cpu_supports(zend_cpu_feature feature);
* functions */
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse2(void) {
#ifdef __aarch64__
return 0;
#else
#ifdef PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse2");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse3(void) {
#ifdef __aarch64__
return 0;
#else
#ifdef PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse3");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_ssse3(void) {
#ifdef __aarch64__
return 0;
#else
#ifdef PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("ssse3");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse41(void) {
#ifdef __aarch64__
return 0;
#else
#ifdef PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse4.1");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse42(void) {
#ifdef __aarch64__
return 0;
#else
#ifdef PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse4.2");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_avx(void) {
#ifdef __aarch64__
return 0;
#else
#ifdef PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("avx");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_avx2(void) {
#ifdef __aarch64__
return 0;
#else
#ifdef PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("avx2");
#endif
}

#ifdef PHP_HAVE_AVX512_SUPPORTS
Expand Down
7 changes: 7 additions & 0 deletions ext/bcmath/bcmath.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,12 @@ static zval *bcmath_number_read_property(zend_object *obj, zend_string *name, in
return zend_std_read_property(obj, name, type, cache_slot, rv);
}

static zval *bcmath_number_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot)
{
/* Must always go through read property because all properties are virtual, and no dynamic properties are allowed. */
return NULL;
}

static int bcmath_number_has_property(zend_object *obj, zend_string *name, int check_empty, void **cache_slot)
{
if (check_empty == ZEND_PROPERTY_NOT_EMPTY) {
Expand Down Expand Up @@ -1034,6 +1040,7 @@ static void bcmath_number_register_class(void)
bcmath_number_obj_handlers.unset_property = bcmath_number_unset_property;
bcmath_number_obj_handlers.has_property = bcmath_number_has_property;
bcmath_number_obj_handlers.read_property = bcmath_number_read_property;
bcmath_number_obj_handlers.get_property_ptr_ptr = bcmath_number_get_property_ptr_ptr;
bcmath_number_obj_handlers.get_properties_for = bcmath_number_get_properties_for;
bcmath_number_obj_handlers.cast_object = bcmath_number_cast_object;
}
Expand Down
13 changes: 13 additions & 0 deletions ext/bcmath/tests/number/gh18641.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
GH-18641 (Accessing a BcMath\Number property by ref crashes)
--EXTENSIONS--
bcmath
--FILE--
<?php
$a = new BCMath\Number("1");
$fusion = $a;
$x = &$fusion->value;
var_dump($x);
?>
--EXPECT--
string(1) "1"
3 changes: 2 additions & 1 deletion ext/readline/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,14 @@ char **php_readline_completion_cb(const char *text, int start, int end)
/* libedit will read matches[2] */
matches = calloc(3, sizeof(char *));
if (!matches) {
return NULL;
goto out;
}
matches[0] = strdup("");
}
}
}

out:
zval_ptr_dtor(&params[0]);
zval_ptr_dtor(&_readline_array);

Expand Down
2 changes: 2 additions & 0 deletions ext/soap/php_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ int make_http_soap_request(zval *this_ptr,
} else {
zval_ptr_dtor(&params[0]);
zval_ptr_dtor(&func);
zval_ptr_dtor(&retval);
if (request != buf) {
zend_string_release_ex(request, 0);
}
Expand Down Expand Up @@ -1329,6 +1330,7 @@ int make_http_soap_request(zval *this_ptr,
} else {
zval_ptr_dtor(&params[0]);
zval_ptr_dtor(&func);
zval_ptr_dtor(&retval);
efree(content_encoding);
zend_string_release_ex(http_headers, 0);
zend_string_release_ex(http_body, 0);
Expand Down