Skip to content

Commit 90dc920

Browse files
committed
ValueError if lengths is less than 0
1 parent 2a49962 commit 90dc920

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ext/pgsql/pgsql.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ PHP_FUNCTION(pg_lo_close)
25622562
PHP_FUNCTION(pg_lo_read)
25632563
{
25642564
zval *pgsql_id;
2565-
zend_long len;
2565+
zend_long len = 0;
25662566
size_t buf_len = PGSQL_LO_READ_BUF_SIZE;
25672567
int nbytes;
25682568
zend_string *buf;
@@ -2576,8 +2576,9 @@ PHP_FUNCTION(pg_lo_read)
25762576
RETURN_THROWS();
25772577
}
25782578

2579-
if (ZEND_NUM_ARGS() > 1) {
2580-
buf_len = len < 0 ? 0 : len;
2579+
if (len < 0) {
2580+
zend_argument_value_error(2, "must be greater or equal than 0");
2581+
RETURN_THROWS();
25812582
}
25822583

25832584
buf = zend_string_alloc(buf_len, 0);

0 commit comments

Comments
 (0)