From c29ebd8a23cf1127d6b0d42fd2cc604834d3b84e Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Thu, 13 Nov 2008 18:14:50 +0000 Subject: - MFH: Better fix --- ext/pdo/pdo_sql_parser.re | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'ext/pdo/pdo_sql_parser.re') 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); } -- cgit v1.2.1