]> granicus.if.org Git - php/commitdiff
Don't accept null in pg_unescape_bytea()
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 13 Oct 2020 13:36:09 +0000 (15:36 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 13 Oct 2020 13:37:13 +0000 (15:37 +0200)
This is an error that slipped in via 8d37c37bcdbf6fa99cd275413342457eeb2c664e.
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.

ext/pgsql/pgsql.c
ext/pgsql/pgsql.stub.php
ext/pgsql/pgsql_arginfo.h

index 88cf0c431eeb4bec41cb8946e6e82fbdca5648f3..aac2afd4936be8f7af2f3e0eae28bc01304d032d 100644 (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();
        }
 
index 66044b95a5b4c571cb4209f3ba3b618c25f0823c..759313d8ba6605df0f94a8858dd6ba52eeaaf0c5 100644 (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 {}
index be9edb2c57afe6b23499459af82bd1be0ba9c815..6db1b8a1c3f611ec0ce5a443f86a2874019259ec 100644 (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)