xref: /PHP-7.3/ext/mysqli/tests/bug48909.phpt (revision b746e698)
1--TEST--
2Bug #48909 (Segmentation fault in mysqli_stmt_execute)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10	require_once("connect.inc");
11
12	if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
13		printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
14			$host, $user, $db, $port, $socket);
15
16	if (!$link->query("DROP TABLE IF EXISTS test") ||
17		!$link->query(sprintf("CREATE TABLE test(id INT, label varchar(255)) ENGINE = %s", $engine)))
18		printf("[002] [%d] %s\n", $link->errno, $link->error);
19
20	if (!$stmt = $link->prepare("INSERT INTO test(id, label) VALUES  (?, ?)"))
21		printf("[003] [%d] %s\n", $link->errno, $link->error);
22
23	if (!$stmt->bind_param("bb",$bvar, $bvar))
24		printf("[004] [%d] %s\n", $stmt->errno, $stmt->error);
25
26	if (!$stmt->execute()) {
27		if ($stmt->errno != 1366) {
28			/*
29				$bvar is null, b is for BLOB - any error like this should be OK:
30				1366 -  Incorrect integer value: '' for column 'id' at row 1
31			*/
32			printf("[005] [%d] %s\n", $stmt->errno, $stmt->error);
33		}
34	}
35
36	$stmt->close();
37	$link->close();
38
39	echo "done";
40?>
41--CLEAN--
42<?php
43	require_once("clean_table.inc");
44?>
45--EXPECT--
46done
47