]> granicus.if.org Git - php/commitdiff
fix more leaks. handle better unknown type (4.1.x connected to 5.0.x
authorAndrey Hristov <andrey@php.net>
Wed, 30 Nov 2005 15:26:41 +0000 (15:26 +0000)
committerAndrey Hristov <andrey@php.net>
Wed, 30 Nov 2005 15:26:41 +0000 (15:26 +0000)
incompatibility)

ext/mysqli/mysqli_api.c
ext/mysqli/tests/013.phpt

index 9ade72bb8cf903b6a939cc1ba2887153420a892d..7e4ef4d027b5d5cb2a3ea214b61224b80967cf7b 100644 (file)
@@ -345,6 +345,9 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
                                bind[ofs].buffer_length = stmt->result.buf[ofs].buflen;
                                bind[ofs].length = &stmt->result.buf[ofs].buflen;
                                break;
+                       default:
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Server returned unknown type %ld. Probably your client library is incompatible with the server version you use!", col_type);
+                               break;
                }
        }
 
@@ -354,9 +357,13 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
        if (rc) {
                efree(bind);
                efree(args);
-                /* dont close the statement or subsequent usage (for example ->execute()) will lead to crash */
-                efree(stmt->result.buf);
-                efree(stmt->result.is_null);
+               /* dont close the statement or subsequent usage (for example ->execute()) will lead to crash */
+               for (i=0; i < var_cnt ; i++) {
+                       if (stmt->result.buf[i].val)        
+                               efree(stmt->result.buf[i].val);
+               }
+               efree(stmt->result.buf);
+               efree(stmt->result.is_null);
                RETURN_FALSE;
        }
 
index ff435f94db99b11abb644b2d0841e10e94d1d100..983ceba14ceff58d453a5100aa0a28b2afdd4639 100644 (file)
@@ -25,7 +25,7 @@ mysqli fetch mixed / mysql_query
        $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
 
        $c = array(0,0,0,0,0,0,0,0);
-       mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
+       $b_res= mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
        mysqli_execute($stmt);
        mysqli_fetch($stmt); 
        mysqli_fetch($stmt);  
@@ -38,10 +38,15 @@ mysqli fetch mixed / mysql_query
        $test = "";
        for ($i=0; $i < count($c); $i++)
                $test .= ($c[0] == $d[0]) ? "1" : "0";
-
-       var_dump($test);
+       if ($test == "11111111")
+               echo "ok";
+       else if ($b_res == FALSE && mysqli_get_client_version() > 40100 && mysqli_get_client_version() < 50000 &&
+                 mysqli_get_server_version($link) > 50000)
+               echo "error (4.1 library with 5.x server)";
+       else
+               echo "error";
 
        mysqli_close($link);
 ?>
---EXPECT--
-string(8) "11111111"
+--EXPECTF--
+ok