1
0
mirror of https://github.com/php/php-src.git synced 2026-04-27 18:23:26 +02:00
Files
archived-php-src/Zend/tests/match/037.phpt
T
Ilija Tovilo 1c967df5a0 Fix free of uninitialized memory in MATCH_ERROR
As suggested by Tyson Andre:
https://github.com/php/php-src/pull/5371#issuecomment-657081464

Also fix line number of unhandled match error

Closes GH-5841.
2020-07-12 13:33:36 +02:00

70 lines
1.2 KiB
PHP

--TEST--
Test match jumptable with only one arm
--FILE--
<?php
try {
var_dump(match(true) {
1, 2, 3, 4, 5 => 'foo',
});
} catch (Error $e) {
var_dump((string) $e);
}
try {
var_dump(match(6) {
1, 2, 3, 4, 5 => 'foo',
});
} catch (Error $e) {
var_dump((string) $e);
}
try {
var_dump(match('3') {
1, 2, 3, 4, 5 => 'foo',
});
} catch (Error $e) {
var_dump((string) $e);
}
var_dump(match(3) {
1, 2, 3, 4, 5 => 'foo',
});
var_dump(match(true) {
1, 2, 3, 4, 5 => 'foo',
default => 'bar',
});
var_dump(match(6) {
1, 2, 3, 4, 5 => 'foo',
default => 'bar',
});
var_dump(match('3') {
1, 2, 3, 4, 5 => 'foo',
default => 'bar',
});
var_dump(match(3) {
1, 2, 3, 4, 5 => 'foo',
default => 'bar',
});
?>
--EXPECTF--
string(%d) "UnhandledMatchError: Unhandled match value of type bool in %s037.php:4
Stack trace:
#0 {main}"
string(%d) "UnhandledMatchError: Unhandled match value of type int in %s037.php:12
Stack trace:
#0 {main}"
string(%d) "UnhandledMatchError: Unhandled match value of type string in %s037.php:20
Stack trace:
#0 {main}"
string(3) "foo"
string(3) "bar"
string(3) "bar"
string(3) "bar"
string(3) "foo"