Don't accept null in pg_unescape_bytea()

This is an error that slipped in via 8d37c37bcd.
pg_unescape_bytea() did not accept null in PHP 7.4, and it is not
meaningful for it to accept null now -- it will always fail, and now
with a misleading OOM message.
This commit is contained in:
Nikita Popov 2020-10-13 15:36:09 +02:00
parent 8e531b5b00
commit 7b0f5f424d
3 changed files with 5 additions and 6 deletions

View File

@ -3359,8 +3359,7 @@ PHP_FUNCTION(pg_unescape_bytea)
char *from, *tmp;
size_t to_len;
size_t from_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!",
&from, &from_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &from, &from_len) == FAILURE) {
RETURN_THROWS();
}

View File

@ -425,7 +425,7 @@ function pg_escape_string($connection, string $string = UNKNOWN): string {}
/** @param resource|string $connection */
function pg_escape_bytea($connection, string $string = UNKNOWN): string {}
function pg_unescape_bytea(?string $string = null): string {}
function pg_unescape_bytea(string $string): string {}
/** @param resource|string $connection */
function pg_escape_literal($connection, string $string = UNKNOWN): string|false {}

View File

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 3479aee134cb8d952c846d120f51a8cf75e55e86 */
* Stub hash: deb01afb2b4e645c00684fae61a6042ebfbaaaa1 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_connect, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, connection_string, IS_STRING, 0)
@ -327,8 +327,8 @@ ZEND_END_ARG_INFO()
#define arginfo_pg_escape_bytea arginfo_pg_escape_string
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pg_unescape_bytea, 0, 0, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, string, IS_STRING, 1, "null")
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pg_unescape_bytea, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pg_escape_literal, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)