summaryrefslogtreecommitdiff
path: root/ext/pdo/pdo_sql_parser.re
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-11-13 18:14:50 +0000
committerFelipe Pena <felipe@php.net>2008-11-13 18:14:50 +0000
commitc29ebd8a23cf1127d6b0d42fd2cc604834d3b84e (patch)
tree0bd9961996f74b559b982ab0281c1cf202c38b37 /ext/pdo/pdo_sql_parser.re
parentc8103324bf2561efda883169e8f65de82871e923 (diff)
downloadphp-git-c29ebd8a23cf1127d6b0d42fd2cc604834d3b84e.tar.gz
- MFH: Better fix
Diffstat (limited to 'ext/pdo/pdo_sql_parser.re')
-rw-r--r--ext/pdo/pdo_sql_parser.re11
1 files changed, 4 insertions, 7 deletions
diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re
index d9ac6ef2ec..60f49c1809 100644
--- a/ext/pdo/pdo_sql_parser.re
+++ b/ext/pdo/pdo_sql_parser.re
@@ -299,9 +299,8 @@ rewrite:
} else if (query_type == PDO_PLACEHOLDER_POSITIONAL) {
/* rewrite ? to :pdoX */
- char idxbuf[32];
+ char *name, *idxbuf;
const char *tmpl = stmt->named_rewrite_template ? stmt->named_rewrite_template : ":pdo%d";
- char *name;
int bind_no = 1;
newbuffer_len = inquery_len;
@@ -318,21 +317,19 @@ rewrite:
/* check if bound parameter is already available */
if (!strcmp(name, "?") || zend_hash_find(stmt->bound_param_map, name, plc->len + 1, (void**) &p) == FAILURE) {
- snprintf(idxbuf, sizeof(idxbuf), tmpl, bind_no++);
+ spprintf(&idxbuf, 0, tmpl, bind_no++);
} else {
- memset(idxbuf, 0, sizeof(idxbuf));
- memcpy(idxbuf, p, strlen(p));
+ idxbuf = estrdup(p);
skip_map = 1;
}
- plc->quoted = estrdup(idxbuf);
+ plc->quoted = idxbuf;
plc->qlen = strlen(plc->quoted);
plc->freeq = 1;
newbuffer_len += plc->qlen;
if (!skip_map && stmt->named_rewrite_template) {
/* create a mapping */
-
zend_hash_update(stmt->bound_param_map, name, plc->len + 1, idxbuf, plc->qlen + 1, NULL);
}