php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #67919
Patch pdorealloc revision 2014-08-27 18:18 UTC by pm at datasphere dot ch

Patch pdorealloc for PDO ODBC Bug #67919

Patch version 2014-08-27 18:18 UTC

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

Developer: pm@datasphere.ch

diff -Naurp php-5.5.15.orig/ext/pdo_odbc/odbc_stmt.c php-5.5.15.new/ext/pdo_odbc/odbc_stmt.c
--- php-5.5.15.orig/ext/pdo_odbc/odbc_stmt.c	2014-07-23 11:00:58.000000000 +0200
+++ php-5.5.15.new/ext/pdo_odbc/odbc_stmt.c	2014-08-26 19:29:57.313458322 +0200
@@ -468,37 +468,33 @@ static int odbc_stmt_param_hook(pdo_stmt
 			
 			case PDO_PARAM_EVT_EXEC_POST:
 				P = param->driver_data;
+
 				if (P->outbuf) {
-					if (P->outbuf) {
-						unsigned long ulen;
-						char *srcbuf;
-						unsigned long srclen = 0;
+					unsigned long ulen;
+					char *srcbuf;
+					unsigned long srclen = 0;
+
+					zval_dtor(param->parameter);
+					ZVAL_NULL(param->parameter);
+
+					switch (P->len) {
+						case SQL_NULL_DATA:
+							break;
+						default:
+							switch (pdo_odbc_ucs22utf8(stmt, P->is_unicode, P->outbuf, P->len, &ulen)) {
+								case PDO_ODBC_CONV_FAIL:
+									/* something fishy, but allow it to come back as binary */
+								case PDO_ODBC_CONV_NOT_REQUIRED:
+									srcbuf = P->outbuf;
+									srclen = P->len;
+									break;
+								case PDO_ODBC_CONV_OK:
+									srcbuf = S->convbuf;
+									srclen = ulen;
+									break;
+							}
 
-						switch (P->len) {
-							case SQL_NULL_DATA:
-								zval_dtor(param->parameter);
-								ZVAL_NULL(param->parameter);
-								break;
-							default:
-								convert_to_string(param->parameter);
-								switch (pdo_odbc_ucs22utf8(stmt, P->is_unicode, P->outbuf, P->len, &ulen)) {
-									case PDO_ODBC_CONV_FAIL:
-										/* something fishy, but allow it to come back as binary */
-									case PDO_ODBC_CONV_NOT_REQUIRED:
-										srcbuf = P->outbuf;
-										srclen = P->len;
-										break;
-									case PDO_ODBC_CONV_OK:
-										srcbuf = S->convbuf;
-										srclen = ulen;
-										break;
-								}
-										
-								Z_STRVAL_P(param->parameter) = erealloc(Z_STRVAL_P(param->parameter), srclen+1);
-								memcpy(Z_STRVAL_P(param->parameter), srcbuf, srclen);
-								Z_STRLEN_P(param->parameter) = srclen;
-								Z_STRVAL_P(param->parameter)[srclen] = '\0';
-						}
+							ZVAL_STRINGL(param->parameter, srcbuf, srclen, 1);
 					}
 				}
 				return 1;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC