xref: /php-src/ext/openssl/tests/bug38261.phpt (revision 74859783)
1--TEST--
2openssl key from zval leaks
3--EXTENSIONS--
4openssl
5--FILE--
6<?php
7$cert = false;
8class test {
9    function __toString() {
10        return "test object";
11    }
12}
13$t = new test;
14
15var_dump(openssl_x509_parse("foo"));
16
17try {
18    var_dump(openssl_x509_parse($t));
19} catch (TypeError $e) {
20    echo $e->getMessage(), "\n";
21}
22
23try {
24    openssl_x509_parse([]);
25} catch (TypeError $e) {
26    echo $e->getMessage(), "\n";
27}
28
29var_dump(openssl_x509_parse($cert));
30
31try {
32    openssl_x509_parse(new stdClass);
33} catch (TypeError $e) {
34    echo $e->getMessage(), "\n";
35}
36
37?>
38--EXPECT--
39bool(false)
40bool(false)
41openssl_x509_parse(): Argument #1 ($certificate) must be of type OpenSSLCertificate|string, array given
42bool(false)
43openssl_x509_parse(): Argument #1 ($certificate) must be of type OpenSSLCertificate|string, stdClass given
44