xref: /PHP-8.0/ext/openssl/tests/bug38261.phpt (revision e8e4ddce)
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"));
18
19try {
20    var_dump(openssl_x509_parse($t));
21} catch (TypeError $e) {
22    echo $e->getMessage(), "\n";
23}
24
25try {
26    openssl_x509_parse([]);
27} catch (TypeError $e) {
28    echo $e->getMessage(), "\n";
29}
30
31var_dump(openssl_x509_parse($cert));
32
33try {
34    openssl_x509_parse(new stdClass);
35} catch (TypeError $e) {
36    echo $e->getMessage(), "\n";
37}
38
39?>
40--EXPECT--
41bool(false)
42bool(false)
43openssl_x509_parse(): Argument #1 ($certificate) must be of type OpenSSLCertificate|string, array given
44bool(false)
45openssl_x509_parse(): Argument #1 ($certificate) must be of type OpenSSLCertificate|string, stdClass given
46