Skip to content

Commit 960da6d

Browse files
marandallkrakjoe
authored andcommitted
Warnings become errors hash stream functions (other than hash_init)
1 parent 14c07fe commit 960da6d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

ext/hash/hash.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ PHP_FUNCTION(hash_init)
414414

415415
#define PHP_HASHCONTEXT_VERIFY(func, hash) { \
416416
if (!hash->context) { \
417-
php_error(E_WARNING, "%s(): supplied resource is not a valid Hash Context resource", func); \
418-
RETURN_NULL(); \
417+
zend_throw_error(NULL, "%s(): supplied resource is not a valid Hash Context resource", func); \
418+
return; \
419419
} \
420420
}
421421

@@ -585,7 +585,9 @@ PHP_FUNCTION(hash_copy)
585585

586586
if (php_hashcontext_from_object(Z_OBJ_P(return_value))->context == NULL) {
587587
zval_ptr_dtor(return_value);
588-
RETURN_FALSE;
588+
589+
zend_throw_error(NULL, "Cannot copy hash");
590+
return;
589591
}
590592
}
591593
/* }}} */

ext/hash/tests/reuse.phpt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Hash: Attempt to reuse a closed hash context
55

66
$h = hash_init('md5');
77
hash_final($h);
8-
hash_update($h, 'foo');
9-
--EXPECTF--
10-
Warning: hash_update(): supplied resource is not a valid Hash Context resource in %s%eext%ehash%etests%ereuse.php on line %d
8+
try {
9+
hash_update($h, 'foo');
10+
}
11+
catch (\Error $e) {
12+
echo $e->getMessage() . "\n";
13+
}
14+
15+
--EXPECT--
16+
hash_update(): supplied resource is not a valid Hash Context resource

0 commit comments

Comments
 (0)