From f76ce400eb63c56d824c5ddbb367f4ce56b181ac Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 27 Jul 2004 16:40:46 +0000 Subject: [PATCH] MFH: Fixed bug 29395 (sqlite_escape_string() returns bogus data on empty strings). --- NEWS | 2 ++ ext/sqlite/sqlite.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6beedd9682..f085050a50 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2004, PHP 5.0.1 - Fixed unloading of dynamically loaded extensions. (Marcus, kameshj at fastmail dot fm) +- Fixed bug 29395 (sqlite_escape_string() returns bogus data on empty + strings). (Ilia, Tony) - Fixed bug #29368 (The destructor is called when an exception is thrown from the constructor). (Marcus) - Fixed bug #29335 (fetch functions now use MYSQLI_BOTH as default) (Georg) diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index 5e6c228ee9..fee732b0a6 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -2680,12 +2680,14 @@ PHP_FUNCTION(sqlite_escape_string) enclen = php_sqlite_encode_binary(string, stringlen, ret+1); RETVAL_STRINGL(ret, enclen+1, 0); - } else { + } else if (stringlen) { ret = sqlite_mprintf("%q", string); if (ret) { RETVAL_STRING(ret, 1); sqlite_freemem(ret); } + } else { + RETURN_EMPTY_STRING(); } } /* }}} */ -- 2.40.0