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