Skip to content

Commit 31d6f15

Browse files
committed
Merge branch 'master' of https://git.php.net/repository/php-src
2 parents 5373441 + d2e416a commit 31d6f15

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

ext/mysqli/mysqli_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#if !defined(MYSQLI_USE_MYSQLND)
3939
/* {{{ mysqli_tx_cor_options_to_string */
40-
static void mysqli_tx_cor_options_to_string(const MYSQL * const conn, smart_str * str, const unsigned size_t mode)
40+
static void mysqli_tx_cor_options_to_string(const MYSQL * const conn, smart_str * str, const size_t mode)
4141
{
4242
if (mode & TRANS_COR_AND_CHAIN && !(mode & TRANS_COR_AND_NO_CHAIN)) {
4343
if (str->s && str->s->len) {

ext/pgsql/pgsql.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -877,9 +877,9 @@ static char *php_pgsql_PQescapeInternal(PGconn *conn, const char *str, size_t le
877877
#endif
878878

879879
/* {{{ _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)
881881
{
882-
register int i = strlen(message)-1;
882+
register size_t i = strlen(message)-1;
883883

884884
if (i>1 && (message[i-1] == '\r' || message[i-1] == '\n') && message[i] == '.') {
885885
--i;
@@ -964,7 +964,7 @@ static void _php_pgsql_notice_handler(void *resource_id, const char *message)
964964
TSRMLS_FETCH();
965965
if (! PGG(ignore_notices)) {
966966
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);
968968
if (PGG(log_notices)) {
969969
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s", notice->message);
970970
}
@@ -2305,18 +2305,23 @@ PHP_FUNCTION(pg_affected_rows)
23052305
Returns the last notice set by the backend */
23062306
PHP_FUNCTION(pg_last_notice)
23072307
{
2308-
zval *pgsql_link;
2308+
zval *pgsql_link = NULL;
23092309
PGconn *pg_link;
23102310
int id = -1;
23112311
php_pgsql_notice *notice;
23122312

23132313
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pgsql_link) == FAILURE) {
23142314
return;
23152315
}
2316+
2317+
if (pgsql_link == NULL && id == -1) {
2318+
RETURN_FALSE;
2319+
}
2320+
23162321
/* Just to check if user passed valid resoruce */
23172322
ZEND_FETCH_RESOURCE2(pg_link, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
23182323

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) {
23202325
RETURN_FALSE;
23212326
}
23222327
RETURN_STRINGL(notice->message, notice->len);

0 commit comments

Comments
 (0)