Skip to content

Commit 29d0580

Browse files
committed
Clean up IPC objects in arginfo mismatch test
1 parent 3b50874 commit 29d0580

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

Zend/tests/arginfo_zpp_mismatch.phpt

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

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

13+
function cleanupIpcResult($result) {
14+
if ($result instanceof SysvMessageQueue) {
15+
msg_remove_queue($result);
16+
} elseif ($result instanceof SysvSemaphore) {
17+
sem_remove($result);
18+
} elseif ($result instanceof SysvSharedMemory) {
19+
shm_remove($result);
20+
}
21+
}
22+
1323
function test($function) {
1424
if (skipFunction($function)) {
1525
return;
@@ -22,39 +32,51 @@ function test($function) {
2232
echo "Testing " . get_class($function[0]) . "::$function[1]\n";
2333
}
2434
try {
25-
@$function();
35+
cleanupIpcResult(@$function());
2636
} catch (Throwable) {
2737
}
2838
try {
29-
@$function(null);
39+
if ($function === 'msg_queue_exists') {
40+
@$function(1);
41+
} else {
42+
cleanupIpcResult(@$function(null));
43+
}
3044
} catch (Throwable) {
3145
}
3246
try {
33-
@$function(null, null);
47+
cleanupIpcResult(@$function(null, null));
3448
} catch (Throwable) {
3549
}
3650
try {
37-
@$function(null, null, null);
51+
if ($function === 'sem_get' || $function === 'shm_attach') {
52+
cleanupIpcResult(@$function(null, null, 0600));
53+
} else {
54+
cleanupIpcResult(@$function(null, null, null));
55+
}
3856
} catch (Throwable) {
3957
}
4058
try {
41-
@$function(null, null, null, null);
59+
if ($function === 'sem_get') {
60+
cleanupIpcResult(@$function(null, null, 0600, null));
61+
} else {
62+
cleanupIpcResult(@$function(null, null, null, null));
63+
}
4264
} catch (Throwable) {
4365
}
4466
try {
45-
@$function(null, null, null, null, null);
67+
cleanupIpcResult(@$function(null, null, null, null, null));
4668
} catch (Throwable) {
4769
}
4870
try {
49-
@$function(null, null, null, null, null, null);
71+
cleanupIpcResult(@$function(null, null, null, null, null, null));
5072
} catch (Throwable) {
5173
}
5274
try {
53-
@$function(null, null, null, null, null, null, null);
75+
cleanupIpcResult(@$function(null, null, null, null, null, null, null));
5476
} catch (Throwable) {
5577
}
5678
try {
57-
@$function(null, null, null, null, null, null, null, null);
79+
cleanupIpcResult(@$function(null, null, null, null, null, null, null, null));
5880
} catch (Throwable) {
5981
}
6082
ob_end_clean();

0 commit comments

Comments
 (0)