@@ -877,9 +877,9 @@ static char *php_pgsql_PQescapeInternal(PGconn *conn, const char *str, size_t le
877
877
#endif
878
878
879
879
/* {{{ _php_pgsql_trim_message */
880
- static char * _php_pgsql_trim_message (const char * message , int * len )
880
+ static char * _php_pgsql_trim_message (const char * message , size_t * len )
881
881
{
882
- register int i = strlen (message )- 1 ;
882
+ register size_t i = strlen (message )- 1 ;
883
883
884
884
if (i > 1 && (message [i - 1 ] == '\r' || message [i - 1 ] == '\n' ) && message [i ] == '.' ) {
885
885
-- i ;
@@ -964,7 +964,7 @@ static void _php_pgsql_notice_handler(void *resource_id, const char *message)
964
964
TSRMLS_FETCH ();
965
965
if (! PGG (ignore_notices )) {
966
966
notice = (php_pgsql_notice * )emalloc (sizeof (php_pgsql_notice ));
967
- notice -> message = _php_pgsql_trim_message (message , ( int * ) & notice -> len );
967
+ notice -> message = _php_pgsql_trim_message (message , & notice -> len );
968
968
if (PGG (log_notices )) {
969
969
php_error_docref (NULL TSRMLS_CC , E_NOTICE , "%s" , notice -> message );
970
970
}
@@ -2305,18 +2305,23 @@ PHP_FUNCTION(pg_affected_rows)
2305
2305
Returns the last notice set by the backend */
2306
2306
PHP_FUNCTION (pg_last_notice )
2307
2307
{
2308
- zval * pgsql_link ;
2308
+ zval * pgsql_link = NULL ;
2309
2309
PGconn * pg_link ;
2310
2310
int id = -1 ;
2311
2311
php_pgsql_notice * notice ;
2312
2312
2313
2313
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & pgsql_link ) == FAILURE ) {
2314
2314
return ;
2315
2315
}
2316
+
2317
+ if (pgsql_link == NULL && id == -1 ) {
2318
+ RETURN_FALSE ;
2319
+ }
2320
+
2316
2321
/* Just to check if user passed valid resoruce */
2317
2322
ZEND_FETCH_RESOURCE2 (pg_link , PGconn * , pgsql_link , id , "PostgreSQL link" , le_link , le_plink );
2318
2323
2319
- if ((notice = zend_hash_index_find_ptr (& PGG (notices ), Z_RES_HANDLE_P (pgsql_link ))) == NULL ) {
2324
+ if ((notice = zend_hash_index_find_ptr (& PGG (notices ), ( zend_ulong ) Z_RES_HANDLE_P (pgsql_link ))) == NULL ) {
2320
2325
RETURN_FALSE ;
2321
2326
}
2322
2327
RETURN_STRINGL (notice -> message , notice -> len );
0 commit comments