Skip to content

Commit 2d0c76b

Browse files
committed
Clean up IPC objects in arginfo mismatch test
1 parent a5e34c6 commit 2d0c76b

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Zend/tests/arginfo_zpp_mismatch.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@ if (getenv('SKIP_MSAN')) die("skip msan misses interceptors for some functions")
1010

1111
require __DIR__ . "/arginfo_zpp_mismatch.inc";
1212

13+
function testWeakSysvIpcFunction($function): bool {
14+
if (!in_array($function, ['msg_queue_exists', 'msg_get_queue', 'sem_get', 'shm_attach'], true)) {
15+
return false;
16+
}
17+
18+
for ($argumentCount = 0; $argumentCount <= 8; $argumentCount++) {
19+
$arguments = array_fill(0, $argumentCount, null);
20+
if ($function === 'msg_queue_exists' && $argumentCount >= 1) {
21+
$arguments[0] = 1;
22+
}
23+
if (($function === 'sem_get' || $function === 'shm_attach') && $argumentCount >= 3) {
24+
$arguments[2] = 0600;
25+
}
26+
27+
try {
28+
$result = @$function(...$arguments);
29+
if ($result instanceof SysvMessageQueue) {
30+
msg_remove_queue($result);
31+
} elseif ($result instanceof SysvSemaphore) {
32+
sem_remove($result);
33+
} elseif ($result instanceof SysvSharedMemory) {
34+
shm_remove($result);
35+
}
36+
} catch (Throwable) {
37+
}
38+
}
39+
40+
return true;
41+
}
42+
1343
function test($function) {
1444
if (skipFunction($function)) {
1545
return;
@@ -21,6 +51,10 @@ function test($function) {
2151
} else {
2252
echo "Testing " . get_class($function[0]) . "::$function[1]\n";
2353
}
54+
if (testWeakSysvIpcFunction($function)) {
55+
ob_end_clean();
56+
return;
57+
}
2458
try {
2559
@$function();
2660
} catch (Throwable) {

0 commit comments

Comments
 (0)