]> granicus.if.org Git - php/commitdiff
Check before use, because mysqlnd can return NULL
authorAndrey Hristov <andrey@php.net>
Thu, 27 May 2010 12:44:10 +0000 (12:44 +0000)
committerAndrey Hristov <andrey@php.net>
Thu, 27 May 2010 12:44:10 +0000 (12:44 +0000)
and this will crash. However, this can happen only in case of OOM.

ext/mysqli/mysqli_api.c

index 6615b7024f95f431f96a3ac506aada57b19321f5..6150f7179d201c89da5883192a641dc47359d1b2 100644 (file)
@@ -453,10 +453,13 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,
 {
        unsigned int i;
        MYSQLND_RESULT_BIND * params = mysqlnd_stmt_alloc_result_bind(stmt->stmt);
-       for (i = 0; i < (argc - start); i++) {
-               params[i].zv = *(args[i + start]);
+       if (params) {
+               for (i = 0; i < (argc - start); i++) {
+                       params[i].zv = *(args[i + start]);
+               }
+               return mysqlnd_stmt_bind_result(stmt->stmt, params);
        }
-       return mysqlnd_stmt_bind_result(stmt->stmt, params);
+       return FAIL;
 }
 #endif
 /* }}} */