Fixed bug 29395 (sqlite_escape_string() returns bogus data on empty

strings).

Original Patch by: Tony
This commit is contained in:
Ilia Alshanetsky 2004-07-27 16:40:43 +00:00
parent e9549a4f9c
commit fe50278d0a

View File

@ -2680,12 +2680,14 @@ PHP_FUNCTION(sqlite_escape_string)
enclen = php_sqlite_encode_binary(string, stringlen, ret+1); enclen = php_sqlite_encode_binary(string, stringlen, ret+1);
RETVAL_STRINGL(ret, enclen+1, 0); RETVAL_STRINGL(ret, enclen+1, 0);
} else { } else if (stringlen) {
ret = sqlite_mprintf("%q", string); ret = sqlite_mprintf("%q", string);
if (ret) { if (ret) {
RETVAL_STRING(ret, 1); RETVAL_STRING(ret, 1);
sqlite_freemem(ret); sqlite_freemem(ret);
} }
} else {
RETURN_EMPTY_STRING();
} }
} }
/* }}} */ /* }}} */