mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Fix exception handling in shm_put_var() (#19279)
This commit is contained in:
parent
ec0ec47bbf
commit
4c576a2b02
2 changed files with 30 additions and 1 deletions
|
@ -261,7 +261,9 @@ PHP_FUNCTION(shm_put_var)
|
||||||
RETURN_THROWS();
|
RETURN_THROWS();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZEND_ASSERT(shm_var.s != NULL);
|
if (UNEXPECTED(shm_var.s == NULL)) {
|
||||||
|
RETURN_THROWS();
|
||||||
|
}
|
||||||
|
|
||||||
/* insert serialized variable into shared memory */
|
/* insert serialized variable into shared memory */
|
||||||
bool ret = php_put_shm_data(shm_list_ptr->ptr, shm_key, shm_var.s);
|
bool ret = php_put_shm_data(shm_list_ptr->ptr, shm_key, shm_var.s);
|
||||||
|
|
27
ext/sysvshm/tests/serialize_exception.phpt
Normal file
27
ext/sysvshm/tests/serialize_exception.phpt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--TEST--
|
||||||
|
__serialize() exception in shm_put_var()
|
||||||
|
--EXTENSIONS--
|
||||||
|
sysvshm
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$key = ftok(__FILE__, 't');
|
||||||
|
$s = shm_attach($key, 1024);
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
public function __serialize() {
|
||||||
|
throw new Error("no");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
shm_put_var($s, 1, new Test);
|
||||||
|
} catch (Error $exception) {
|
||||||
|
echo $exception->getMessage() . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
shm_remove($s);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
no
|
Loading…
Add table
Add a link
Reference in a new issue