xref: /PHP-8.2/Zend/tests/bug38623.phpt (revision 32e2d97a)
1--TEST--
2Bug #38623 (leaks in a tricky code with switch() and exceptions)
3--FILE--
4<?php
5/* This used to use strtolower, but opcache evaluates that at compile time as of php 8.2 https://wiki.php.net/rfc/strtolower-ascii */
6function create_refcounted_string() {
7    $x = 'bpache';
8    $x[0] = 'a';
9    return $x;
10}
11try {
12    switch(create_refcounted_string()) {
13        case "apache":
14            throw new Exception("test");
15            break;
16    }
17} catch (Exception $e) {
18    echo "ok\n";
19}
20?>
21--EXPECT--
22ok
23