Skip to content

Commit 304a514

Browse files
committed
ext/ldap: Use HASH_FOREACH macro
1 parent 8a9aa08 commit 304a514

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ext/ldap/ldap.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,20 +2291,20 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
22912291
num_berval[i] = num_values;
22922292
ldap_mods[i]->mod_bvalues = safe_emalloc((num_values + 1), sizeof(struct berval *), 0);
22932293

2294-
for (j = 0; j < num_values; j++) {
2295-
zval *ivalue = zend_hash_index_find(Z_ARRVAL_P(value), j);
2296-
ZEND_ASSERT(ivalue != NULL);
2297-
convert_to_string(ivalue);
2294+
zend_ulong attribute_value_index = 0;
2295+
zval *attribute_value = NULL;
2296+
ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(value), attribute_value_index, attribute_value) {
2297+
convert_to_string(attribute_value);
22982298
if (EG(exception)) {
2299-
num_berval[i] = j;
2299+
num_berval[i] = (int)attribute_value_index;
23002300
num_attribs = i + 1;
23012301
RETVAL_FALSE;
23022302
goto cleanup;
23032303
}
2304-
ldap_mods[i]->mod_bvalues[j] = (struct berval *) emalloc (sizeof(struct berval));
2305-
ldap_mods[i]->mod_bvalues[j]->bv_val = Z_STRVAL_P(ivalue);
2306-
ldap_mods[i]->mod_bvalues[j]->bv_len = Z_STRLEN_P(ivalue);
2307-
}
2304+
ldap_mods[i]->mod_bvalues[attribute_value_index] = (struct berval *) emalloc (sizeof(struct berval));
2305+
ldap_mods[i]->mod_bvalues[attribute_value_index]->bv_val = Z_STRVAL_P(attribute_value);
2306+
ldap_mods[i]->mod_bvalues[attribute_value_index]->bv_len = Z_STRLEN_P(attribute_value);
2307+
} ZEND_HASH_FOREACH_END();
23082308
ldap_mods[i]->mod_bvalues[num_values] = NULL;
23092309
}
23102310

0 commit comments

Comments
 (0)