xref: /PHP-7.4/ext/openssl/tests/bug38261.phpt (revision a31f4642)
1--TEST--
2openssl key from zval leaks
3--SKIPIF--
4<?php
5if (!extension_loaded("openssl")) die("skip");
6?>
7--FILE--
8<?php
9$cert = false;
10class test {
11    function __toString() {
12        return "test object";
13    }
14}
15$t = new test;
16
17var_dump(openssl_x509_parse("foo"));
18var_dump(openssl_x509_parse($t));
19var_dump(openssl_x509_parse(array()));
20var_dump(openssl_x509_parse());
21var_dump(openssl_x509_parse($cert));
22try {
23    var_dump(openssl_x509_parse(new stdClass));
24} catch (Error $e) {
25    echo $e->getMessage(), "\n";
26}
27
28?>
29--EXPECTF--
30bool(false)
31bool(false)
32bool(false)
33
34Warning: openssl_x509_parse() expects at least 1 parameter, 0 given in %sbug38261.php on line %d
35NULL
36bool(false)
37Object of class stdClass could not be converted to string
38