From 1998f58b2e691231ae3040b8b5ad210cefd51a8c Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 10 Aug 2024 01:49:25 +0200 Subject: [PATCH] Simplify document standalone setter The logic was very weird as it just should check whether the boolean is true or not. And in fact the code is equivalent because zval_get_long() will only return 0/1 because the type is a bool, and ZEND_NORMALIZE_BOOL won't change that value. --- ext/dom/document.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/dom/document.c b/ext/dom/document.c index a941eb75fd5b..5761e904054d 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -155,8 +155,8 @@ zend_result dom_document_standalone_write(dom_object *obj, zval *newval) { DOM_PROP_NODE(xmlDocPtr, docp, obj); - zend_long standalone = zval_get_long(newval); - docp->standalone = ZEND_NORMALIZE_BOOL(standalone); + ZEND_ASSERT(Z_TYPE_P(newval) == IS_TRUE || Z_TYPE_P(newval) == IS_FALSE); + docp->standalone = Z_TYPE_P(newval) == IS_TRUE; return SUCCESS; }