From: Dmitry Stogov Date: Mon, 16 Mar 2015 12:53:54 +0000 (+0300) Subject: Use memcmp() instead of strncmp() X-Git-Tag: PRE_PHP7_NSAPI_REMOVAL~653 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a6ab089cd28b3ef4504777c0122d788a827b54f;p=php Use memcmp() instead of strncmp() --- diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index ba5619f593..d7cf7ad9c8 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6936,7 +6936,7 @@ ZEND_VM_HANDLER(123, ZEND_TYPE_CHECK, CONST|TMP|VAR|CV, ANY) if (Z_TYPE_P(value) == opline->extended_value) { zend_class_entry *ce = Z_OBJCE_P(value); if (ce->name->len == sizeof("__PHP_Incomplete_Class") - 1 - && !strncmp(ce->name->val, "__PHP_Incomplete_Class", ce->name->len)) { + && !memcmp(ce->name->val, "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1)) { ZVAL_FALSE(EX_VAR(opline->result.var)); } else { ZVAL_TRUE(EX_VAR(opline->result.var)); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 454e97f400..46da517a62 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3820,7 +3820,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_CONST_HANDLER( if (Z_TYPE_P(value) == opline->extended_value) { zend_class_entry *ce = Z_OBJCE_P(value); if (ce->name->len == sizeof("__PHP_Incomplete_Class") - 1 - && !strncmp(ce->name->val, "__PHP_Incomplete_Class", ce->name->len)) { + && !memcmp(ce->name->val, "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1)) { ZVAL_FALSE(EX_VAR(opline->result.var)); } else { ZVAL_TRUE(EX_VAR(opline->result.var)); @@ -9976,7 +9976,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_TMP_HANDLER(ZE if (Z_TYPE_P(value) == opline->extended_value) { zend_class_entry *ce = Z_OBJCE_P(value); if (ce->name->len == sizeof("__PHP_Incomplete_Class") - 1 - && !strncmp(ce->name->val, "__PHP_Incomplete_Class", ce->name->len)) { + && !memcmp(ce->name->val, "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1)) { ZVAL_FALSE(EX_VAR(opline->result.var)); } else { ZVAL_TRUE(EX_VAR(opline->result.var)); @@ -13324,7 +13324,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_VAR_HANDLER(ZE if (Z_TYPE_P(value) == opline->extended_value) { zend_class_entry *ce = Z_OBJCE_P(value); if (ce->name->len == sizeof("__PHP_Incomplete_Class") - 1 - && !strncmp(ce->name->val, "__PHP_Incomplete_Class", ce->name->len)) { + && !memcmp(ce->name->val, "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1)) { ZVAL_FALSE(EX_VAR(opline->result.var)); } else { ZVAL_TRUE(EX_VAR(opline->result.var)); @@ -26165,7 +26165,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_CV_HANDLER(ZEN if (Z_TYPE_P(value) == opline->extended_value) { zend_class_entry *ce = Z_OBJCE_P(value); if (ce->name->len == sizeof("__PHP_Incomplete_Class") - 1 - && !strncmp(ce->name->val, "__PHP_Incomplete_Class", ce->name->len)) { + && !memcmp(ce->name->val, "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1)) { ZVAL_FALSE(EX_VAR(opline->result.var)); } else { ZVAL_TRUE(EX_VAR(opline->result.var)); diff --git a/ext/standard/type.c b/ext/standard/type.c index d6ea5d58ec..f884017f6f 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -228,7 +228,7 @@ static inline void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type) if (type == IS_OBJECT) { zend_class_entry *ce = Z_OBJCE_P(arg); if (ce->name->len == sizeof(INCOMPLETE_CLASS) - 1 - && !strncmp(ce->name->val, INCOMPLETE_CLASS, ce->name->len)) { + && !memcmp(ce->name->val, INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1)) { RETURN_FALSE; } } else if (type == IS_RESOURCE) {