Skip to content

Commit ef9ab91

Browse files
committed
Use assertion for null-termination string
Indicates an implementation bug, make sure we can automatically detect it.
1 parent 94854e0 commit ef9ab91

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Zend/zend_API.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,12 +638,9 @@ END_EXTERN_C()
638638

639639
#if ZEND_DEBUG
640640
#define CHECK_ZVAL_STRING(str) \
641-
if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s)", ZSTR_VAL(str)); }
642-
#define CHECK_ZVAL_STRING_REL(str) \
643-
if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
641+
ZEND_ASSERT(ZSTR_VAL(str)[ZSTR_LEN(str)] == '\0' && "String is not null-terminated");
644642
#else
645643
#define CHECK_ZVAL_STRING(z)
646-
#define CHECK_ZVAL_STRING_REL(z)
647644
#endif
648645

649646
#define CHECK_ZVAL_NULL_PATH(p) (Z_STRLEN_P(p) != strlen(Z_STRVAL_P(p)))

0 commit comments

Comments
 (0)