From 48ff226caeaef37863736297bbe807ac5ec4784b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 29 Aug 2019 18:01:34 +0200 Subject: [PATCH] Fix potentially uninitialized use in ldap If ctrl->ldctl_value.bv_len is zero context is uninitialized. Only free it if the call took place and succeeded. --- ext/ldap/ldap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 44c9e2f493..d6fefb7850 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -265,10 +265,10 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, add_assoc_stringl(&value, "context", context->bv_val, context->bv_len); } add_assoc_zval(array, "value", &value); + ber_bvfree(context); } else { add_assoc_null(array, "value"); } - ber_bvfree(context); } else { if (ctrl->ldctl_value.bv_len) { add_assoc_stringl(array, "value", ctrl->ldctl_value.bv_val, ctrl->ldctl_value.bv_len); -- 2.40.0