]> granicus.if.org Git - php/commitdiff
Assert that cpuinfo is initialized before use
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 27 Nov 2020 10:14:07 +0000 (11:14 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 27 Nov 2020 10:14:07 +0000 (11:14 +0100)
And fix some incorrect indentation.

Zend/zend_cpuinfo.c
Zend/zend_cpuinfo.h

index 8851764f5734ebfc231b8dfa914a0640dde76f9e..81e3f43c51f09456dd00239eebc672c02c83caf7 100644 (file)
@@ -99,6 +99,7 @@ void zend_cpu_startup(void)
 }
 
 ZEND_API int zend_cpu_supports(zend_cpu_feature feature) {
+       ZEND_ASSERT(cpuinfo.initialized);
        if (feature & ZEND_CPU_EDX_MASK) {
                return (cpuinfo.edx & (feature & ~ZEND_CPU_EDX_MASK));
        } else if (feature & ZEND_CPU_EBX_MASK) {
index 0baec57c23a885cb8a7e65041bd2a9d28937b2be..8d08d0eb0002e6939ccb3cf2f6d724a0d27c8af6 100644 (file)
@@ -164,9 +164,9 @@ static zend_always_inline int zend_cpu_supports_sse42() {
 ZEND_NO_SANITIZE_ADDRESS
 static zend_always_inline int zend_cpu_supports_pclmul() {
 #if PHP_HAVE_BUILTIN_CPU_INIT
-        __builtin_cpu_init();
+       __builtin_cpu_init();
 #endif
-        return __builtin_cpu_supports("pclmul");
+       return __builtin_cpu_supports("pclmul");
 }
 #endif
 
@@ -208,7 +208,7 @@ static zend_always_inline int zend_cpu_supports_sse42() {
 }
 
 static zend_always_inline int zend_cpu_supports_pclmul() {
-        return zend_cpu_supports(ZEND_CPU_FEATURE_PCLMULQDQ);
+       return zend_cpu_supports(ZEND_CPU_FEATURE_PCLMULQDQ);
 }
 
 static zend_always_inline int zend_cpu_supports_avx() {