Skip to content

Commit d468b5b

Browse files
committed
hash: Don't carry passed initialization args through
Signed-off-by: Anatol Belski <ab@php.net>
1 parent 4886816 commit d468b5b

File tree

2 files changed

+3
-31
lines changed

2 files changed

+3
-31
lines changed

ext/hash/hash.c

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -643,12 +643,6 @@ PHP_FUNCTION(hash_init)
643643
hash->context = context;
644644
hash->options = options;
645645
hash->key = NULL;
646-
if (args && zend_hash_num_elements(args)) {
647-
hash->args = args;
648-
GC_TRY_ADDREF(hash->args);
649-
} else {
650-
hash->args = NULL;
651-
}
652646

653647
if (options & PHP_HASH_HMAC) {
654648
char *K = emalloc(ops->block_size);
@@ -803,7 +797,7 @@ PHP_FUNCTION(hash_final)
803797
}
804798

805799
/* Feed this result into the outer hash */
806-
hash->ops->hash_init(hash->context, hash->args);
800+
hash->ops->hash_init(hash->context, NULL);
807801
hash->ops->hash_update(hash->context, hash->key, hash->ops->block_size);
808802
hash->ops->hash_update(hash->context, (unsigned char *) ZSTR_VAL(digest), hash->ops->digest_size);
809803
hash->ops->hash_final((unsigned char *) ZSTR_VAL(digest), hash->context);
@@ -1392,11 +1386,6 @@ static void php_hashcontext_dtor(zend_object *obj) {
13921386
efree(hash->key);
13931387
hash->key = NULL;
13941388
}
1395-
1396-
if (hash->args) {
1397-
zend_array_release(hash->args);
1398-
hash->args = NULL;
1399-
}
14001389
}
14011390
/* }}} */
14021391

@@ -1411,7 +1400,7 @@ static zend_object *php_hashcontext_clone(zend_object *zobj) {
14111400
newobj->ops = oldobj->ops;
14121401
newobj->options = oldobj->options;
14131402
newobj->context = php_hash_alloc_context(newobj->ops);
1414-
newobj->ops->hash_init(newobj->context, oldobj->args);
1403+
newobj->ops->hash_init(newobj->context, NULL);
14151404

14161405
if (SUCCESS != newobj->ops->hash_copy(newobj->ops, oldobj->context, newobj->context)) {
14171406
efree(newobj->context);
@@ -1487,14 +1476,6 @@ PHP_METHOD(HashContext, __serialize)
14871476
Z_TRY_ADDREF(tmp);
14881477
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
14891478

1490-
if (hash->args) {
1491-
ZVAL_ARR(&tmp, hash->args);
1492-
Z_TRY_ADDREF(tmp);
1493-
} else {
1494-
ZVAL_NULL(&tmp);
1495-
}
1496-
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
1497-
14981479
return;
14991480

15001481
serialize_failure:
@@ -1558,14 +1539,7 @@ PHP_METHOD(HashContext, __unserialize)
15581539
hash->ops = ops;
15591540
hash->context = php_hash_alloc_context(ops);
15601541
hash->options = options;
1561-
if (args_zv && IS_ARRAY == Z_TYPE_P(args_zv) && zend_hash_num_elements(Z_ARRVAL_P(args_zv)) > 0) {
1562-
ops->hash_init(hash->context, Z_ARRVAL_P(args_zv));
1563-
hash->args = Z_ARRVAL_P(args_zv);
1564-
GC_TRY_ADDREF(hash->args);
1565-
} else {
1566-
ops->hash_init(hash->context, NULL);
1567-
hash->args = NULL;
1568-
}
1542+
ops->hash_init(hash->context, NULL);
15691543

15701544
unserialize_result = ops->hash_unserialize(hash, magic, hash_zv);
15711545
if (unserialize_result != SUCCESS) {

ext/hash/php_hash.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ struct _php_hashcontext_object {
6161
zend_long options;
6262
unsigned char *key;
6363

64-
HashTable *args;
65-
6664
zend_object std;
6765
};
6866

0 commit comments

Comments
 (0)