summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-12-23 15:58:10 +0100
committerGeorge Peter Banyard <girgias@php.net>2021-01-07 15:53:48 +0000
commit63cda0fea83d19d17d19df18d712328372e7891c (patch)
tree805c6ddfeeb5fd2de0920bf976e091702e41e9cf /ext/pdo_sqlite
parentdf0fa5b1787c6b26b6abfb721d7b5a00b77a1fb6 (diff)
downloadphp-git-63cda0fea83d19d17d19df18d712328372e7891c.tar.gz
Refactor PDO's quoter handler to return a zend_string
Closes GH-6547
Diffstat (limited to 'ext/pdo_sqlite')
-rw-r--r--ext/pdo_sqlite/sqlite_driver.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
index 344850b099..ca069ec300 100644
--- a/ext/pdo_sqlite/sqlite_driver.c
+++ b/ext/pdo_sqlite/sqlite_driver.c
@@ -227,12 +227,14 @@ static char *pdo_sqlite_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t
}
/* NB: doesn't handle binary strings... use prepared stmts for that */
-static bool sqlite_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype )
+static zend_string* sqlite_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquoted, enum pdo_param_type paramtype)
{
- *quoted = safe_emalloc(2, unquotedlen, 3);
- sqlite3_snprintf(2*unquotedlen + 3, *quoted, "'%q'", unquoted);
- *quotedlen = strlen(*quoted);
- return true;
+ char *quoted = safe_emalloc(2, ZSTR_LEN(unquoted), 3);
+ /* TODO use %Q format? */
+ sqlite3_snprintf(2*ZSTR_LEN(unquoted) + 3, quoted, "'%q'", ZSTR_VAL(unquoted));
+ zend_string *quoted_str = zend_string_init(quoted, strlen(quoted), 0);
+ efree(quoted);
+ return quoted_str;
}
static bool sqlite_handle_begin(pdo_dbh_t *dbh)