1--TEST-- 2Bug #70949 (SQL Result Sets With NULL Can Cause Fatal Memory Errors) 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7require_once("connect.inc"); 8if (!$IS_MYSQLND) { 9 die("skip mysqlnd only test"); 10} 11?> 12--FILE-- 13<?php 14require_once("connect.inc"); 15$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); 16 17$mysql->query("DROP TABLE IF EXISTS bug70949"); 18$mysql->query("CREATE TABLE bug70949(name varchar(255))"); 19$mysql->query("INSERT INTO bug70949 VALUES ('dummy'),(NULL),('foo'),('bar')"); 20 21$sql = "select * from bug70949"; 22 23if ($stmt = $mysql->prepare($sql)) 24{ 25 $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY); 26 27 if ($stmt->bind_result($name)) { 28 { 29 if ($stmt->execute()) 30 { 31 while ($stmt->fetch()) 32 { 33 var_dump($name); 34 } 35 } 36 } 37 38 $stmt->free_result(); 39 $stmt->close(); 40 } 41 42 43 $mysql->close(); 44} 45 46?> 47--CLEAN-- 48<?php 49require_once("connect.inc"); 50if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 51 printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 52 53if (!mysqli_query($link, "DROP TABLE IF EXISTS bug70949")) 54 printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 55 56mysqli_close($link); 57?> 58--EXPECT-- 59string(5) "dummy" 60NULL 61string(3) "foo" 62string(3) "bar" 63