Skip to content

Commit 7b0f5f4

Browse files
committed
Don't accept null in pg_unescape_bytea()
This is an error that slipped in via 8d37c37. 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.
1 parent 8e531b5 commit 7b0f5f4

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

ext/pgsql/pgsql.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,8 +3359,7 @@ PHP_FUNCTION(pg_unescape_bytea)
33593359
char *from, *tmp;
33603360
size_t to_len;
33613361
size_t from_len;
3362-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!",
3363-
&from, &from_len) == FAILURE) {
3362+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &from, &from_len) == FAILURE) {
33643363
RETURN_THROWS();
33653364
}
33663365

ext/pgsql/pgsql.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ function pg_escape_string($connection, string $string = UNKNOWN): string {}
425425
/** @param resource|string $connection */
426426
function pg_escape_bytea($connection, string $string = UNKNOWN): string {}
427427

428-
function pg_unescape_bytea(?string $string = null): string {}
428+
function pg_unescape_bytea(string $string): string {}
429429

430430
/** @param resource|string $connection */
431431
function pg_escape_literal($connection, string $string = UNKNOWN): string|false {}

ext/pgsql/pgsql_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 3479aee134cb8d952c846d120f51a8cf75e55e86 */
2+
* Stub hash: deb01afb2b4e645c00684fae61a6042ebfbaaaa1 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_connect, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, connection_string, IS_STRING, 0)
@@ -327,8 +327,8 @@ ZEND_END_ARG_INFO()
327327

328328
#define arginfo_pg_escape_bytea arginfo_pg_escape_string
329329

330-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pg_unescape_bytea, 0, 0, IS_STRING, 0)
331-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, string, IS_STRING, 1, "null")
330+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pg_unescape_bytea, 0, 1, IS_STRING, 0)
331+
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
332332
ZEND_END_ARG_INFO()
333333

334334
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pg_escape_literal, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)

0 commit comments

Comments
 (0)