php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #65946
Patch bug65946.diff revision 2013-11-07 17:58 UTC by rasmus@php.net
revision 2013-11-07 17:56 UTC by rasmus@php.net
revision 2013-11-07 17:54 UTC by rasmus@php.net

Patch bug65946.diff for PDO related Bug #65946

Patch version 2013-11-07 17:58 UTC

Return to Bug #65946 | Download this patch
This patch renders other patches obsolete

Obsolete patches:

Patch Revisions: 2013-11-07 17:58 UTC | 2013-11-07 17:56 UTC | 2013-11-07 17:54 UTC

Developer: rasmus@php.net

Line 1 (now 1), was 65 lines, now 4 lines
 diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
 index aea362f..1664908 100644
 --- a/ext/pdo/pdo_sql_parser.c
 +++ b/ext/pdo/pdo_sql_parser.c
 @@ -586,7 +586,9 @@ safe:
  					}
  					plc->freeq = 1;
  				} else {
 -					switch (Z_TYPE_P(param->parameter)) {
 +					zval tmp_param = *param->parameter;
 +					zval_copy_ctor(&tmp_param);
 +					switch (Z_TYPE(tmp_param)) {
  						case IS_NULL:
  							plc->quoted = "NULL";
  							plc->qlen = sizeof("NULL")-1;
 @@ -594,20 +596,20 @@ safe:
  							break;
  
  						case IS_BOOL:
 -							convert_to_long(param->parameter);
 -
 +							convert_to_long(&tmp_param);
 +							/* fall through */
  						case IS_LONG:
  						case IS_DOUBLE:
 -							convert_to_string(param->parameter);
 -							plc->qlen = Z_STRLEN_P(param->parameter);
 -							plc->quoted = Z_STRVAL_P(param->parameter);
 -							plc->freeq = 0;
 +							convert_to_string(&tmp_param);
 +							plc->qlen = Z_STRLEN(tmp_param);
 +							plc->quoted = estrdup(Z_STRVAL(tmp_param));
 +							plc->freeq = 1;
  							break;
  
  						default:
 -							convert_to_string(param->parameter);
 -							if (!stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),
 -									Z_STRLEN_P(param->parameter), &plc->quoted, &plc->qlen,
 +							convert_to_string(&tmp_param);
 +							if (!stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL(tmp_param),
 +									Z_STRLEN(tmp_param), &plc->quoted, &plc->qlen,
  									param->param_type TSRMLS_CC)) {
  								/* bork */
  								ret = -1;
 @@ -616,6 +618,7 @@ safe:
  							}
  							plc->freeq = 1;
  					}
 +					zval_dtor(&tmp_param);
  				}
  			} else {
  				plc->quoted = Z_STRVAL_P(param->parameter);
 @@ -653,7 +656,6 @@ rewrite:
  		}
  		*newbuffer = '\0';
  		*outquery_len = newbuffer - *outquery;
 -
  		ret = 1;
  		goto clean_up;
  
  diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re
  index 1936a37..fa8ef18 100644
  --- a/ext/pdo/pdo_sql_parser.re
  +++ b/ext/pdo/pdo_sql_parser.re
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Oct 05 02:03:49 2022 UTC