xref: /PHP-8.3/ext/pdo_pgsql/tests/bug70861.phpt (revision 4f84b159)
1--TEST--
2Bug #70861 Segmentation fault in pdo_parse_params() during Drupal 8 test suite
3--EXTENSIONS--
4pdo
5pdo_pgsql
6--SKIPIF--
7<?php
8require __DIR__ . '/config.inc';
9require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
15$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
16
17$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
18
19try {
20    @$db->query("SET bytea_output = 'escape'");
21} catch (Exception $e) {
22}
23
24$db->query('CREATE TABLE test_blob_crash_70861 (id SERIAL NOT NULL, blob1 BYTEA)');
25
26class HelloWrapper {
27    public function stream_open() { return true; }
28    public function stream_eof() { return true; }
29    public function stream_read() { return NULL; }
30    public function stream_stat() { return array(); }
31}
32stream_wrapper_register("hello", "HelloWrapper");
33
34$f = fopen("hello://there", "r");
35
36$stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)", array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
37
38$stmt->bindparam(':foo', $f, PDO::PARAM_LOB);
39$stmt->execute();
40
41fclose($f);
42
43$db->exec('DROP TABLE test_blob_crash');
44
45?>
46+++DONE+++
47--CLEAN--
48<?php
49require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
50$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
51$db->query('DROP TABLE IF EXISTS test_blob_crash_70861 CASCADE');
52?>
53--EXPECTF--
54%a
55+++DONE+++
56