php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #61183
Patch Blob_Bind_Fix revision 2012-10-25 02:31 UTC by james at kenjim dot com

Patch Blob_Bind_Fix for PDO Firebird Bug #61183

Patch version 2012-10-25 02:31 UTC

Return to Bug #61183 | Download this patch
Patch Revisions:

Developer: james@kenjim.com

diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index ae05870..104c4ee 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -424,30 +424,28 @@ static int firebird_bind_blob(pdo_stmt_t *stmt, ISC_QUAD *blob_id, zval *param T
 		return 0;
 	}
 
-	SEPARATE_ZVAL(&param);
-
-	convert_to_string_ex(&param);
+	//Blobs are always strings or nulls.
+	if(Z_TYPE_P(param) == IS_STRING) { //Make sure we did not get passed a NULL
+		char *buffer = Z_STRVAL_P(param);
+		for (rem_cnt = Z_STRLEN_P(param); rem_cnt > 0; rem_cnt -= chunk_size)  {
 	
-	for (rem_cnt = Z_STRLEN_P(param); rem_cnt > 0; rem_cnt -= chunk_size)  {
-
-		chunk_size = rem_cnt > USHRT_MAX ? USHRT_MAX : (unsigned short)rem_cnt;
-
-		if (isc_put_segment(H->isc_status, &h, chunk_size, &Z_STRVAL_P(param)[put_cnt])) {
-			RECORD_ERROR(stmt);
-			result = 0;
-			break;
+			chunk_size = rem_cnt > USHRT_MAX ? USHRT_MAX : (unsigned short)rem_cnt;
+	
+			if (isc_put_segment(H->isc_status, &h, chunk_size, &buffer[put_cnt])) {
+				RECORD_ERROR(stmt);
+				result = 0;
+				break;
+			}
+			put_cnt += chunk_size;
 		}
-		put_cnt += chunk_size;
 	}
-	
-	zval_dtor(param);
 
 	if (isc_close_blob(H->isc_status, &h)) {
 		RECORD_ERROR(stmt);
 		return 0;
 	}
 	return result;
-}	
+}
 
 static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, /* {{{ */
 	enum pdo_param_event event_type TSRMLS_DC)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 00:02:04 2014 UTC