List:Commits« Previous MessageNext Message »
From:ahristov Date:March 12 2007 2:18pm
Subject:PHP mysqlnd svn commit: r102 - trunk/ext/mysqli/mysqlnd
View as plain text  
Author: ahristov
Date: 2007-03-12 14:18:39 +0100 (Mon, 12 Mar 2007)
New Revision: 102

Modified:
   trunk/ext/mysqli/mysqlnd/mysqlnd.c
   trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c
Log:
Fix problems found by valgrind

For cursors check whether stmt passed in is valid.

When extraction is skipped, there are no zvals created, and thus
no way to destroy something, but we will mess also with bounded
things.


Modified: trunk/ext/mysqli/mysqlnd/mysqlnd.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd.c	2007-03-12 11:17:21 UTC (rev 101)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd.c	2007-03-12 13:18:39 UTC (rev 102)
@@ -1141,13 +1141,6 @@
 	  mysqlnd_unbuffered_free_last_data() before it. The function returns always true.
 	*/
 	if (PASS == (ret = PACKET_READ(row_packet, result->conn)) &&
!row_packet->eof) {
-		mysqlnd_unbuffered_free_last_data(result);
-
-		result->last_row_data = row_packet->fields;
-		result->last_row_buffer = row_packet->row_buffer;
-		row_packet->fields = NULL;
-		row_packet->row_buffer = NULL;
-
 		result->row_count++;
 		*fetched_anything = TRUE;
 
@@ -1155,6 +1148,13 @@
 
 		if (!row_packet->skip_extraction) {
 			HashTable *row_ht = Z_ARRVAL_P(row);
+			mysqlnd_unbuffered_free_last_data(result);
+
+			result->last_row_data = row_packet->fields;
+			result->last_row_buffer = row_packet->row_buffer;
+			row_packet->fields = NULL;
+			row_packet->row_buffer = NULL;
+
 			for (i = 0; i < field_count; i++) {
 				zval *data = result->last_row_data[i];
 				int len = (Z_TYPE_P(data) == IS_NULL)? 0:Z_STRLEN_P(data);

Modified: trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c	2007-03-12 11:17:21 UTC (rev 101)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c	2007-03-12 13:18:39 UTC (rev 102)
@@ -537,18 +537,21 @@
 	row_packet->skip_extraction = stmt && stmt->result_bind? FALSE:TRUE;
 
 	/*
-	  If we skip rows (row == NULL) we have to
+	  If we skip rows (stmt == NULL || stmt->result_bind == NULL) we have to
 	  mysqlnd_unbuffered_free_last_data() before it. The function returns always true.
 	*/
 	if (PASS == (ret = PACKET_READ(row_packet, result->conn)) &&
!row_packet->eof) {
-		mysqlnd_unbuffered_free_last_data(result);
+		result->row_count++;
+		*fetched_anything = TRUE;
 
-		result->last_row_data = row_packet->fields;
-		result->last_row_buffer = row_packet->row_buffer;
-		row_packet->fields = NULL;
-		row_packet->row_buffer = NULL;
+		if (!row_packet->skip_extraction) {
+			mysqlnd_unbuffered_free_last_data(result);
 
-		if (!row_packet->skip_extraction) {
+			result->last_row_data = row_packet->fields;
+			result->last_row_buffer = row_packet->row_buffer;
+			row_packet->fields = NULL;
+			row_packet->row_buffer = NULL;
+
 			for (i = 0; i < field_count; i++) {
 				if (stmt->result_bind[i].bound == TRUE) {
 					zval *data = result->last_row_data[i];
@@ -569,9 +572,6 @@
 				}
 			}
 		}
-
-		result->row_count++;
-		*fetched_anything = TRUE;
 	}
 
 	/* Mark the connection as usable again */
@@ -655,6 +655,10 @@
 	zend_uchar buf[STMT_ID_LENGTH /* statement id */ + 4 /* number of rows to fetch */];
 	php_mysql_packet_row *row_packet = result->row_packet;
 
+	if (!stmt) {
+		return FAIL;
+	}
+
 	if (stmt->state < MYSQLND_STMT_USER_FETCHING) {
 		/* Only initted - error */
 		SET_CLIENT_ERROR(stmt->conn->error_info, CR_COMMANDS_OUT_OF_SYNC,
UNKNOWN_SQLSTATE,

Thread
PHP mysqlnd svn commit: r102 - trunk/ext/mysqli/mysqlndahristov12 Mar