mirror of
https://github.com/percona/pg_stat_monitor.git
synced 2026-02-04 05:56:21 +00:00
PG-286: Check for NULL return on hash_search before using object.
Check if hash_search() function returns NULL before attempting to use the object in hash_entry_alloc().
This commit is contained in:
committed by
Hamid Akhtar
parent
b798ffd461
commit
258fa7faa4
@@ -140,7 +140,9 @@ hash_entry_alloc(pgssSharedState *pgss, pgssHashKey *key, int encoding)
|
||||
}
|
||||
/* Find or create an entry with desired hash code */
|
||||
entry = (pgssEntry *) hash_search(pgss_hash, key, HASH_ENTER_NULL, &found);
|
||||
if (!found)
|
||||
if (entry == NULL)
|
||||
pgsm_log_error("hash_entry_alloc: OUT OF MEMORY");
|
||||
else if (!found)
|
||||
{
|
||||
pgss->bucket_entry[pg_atomic_read_u64(&pgss->current_wbucket)]++;
|
||||
/* New entry, initialize it */
|
||||
@@ -152,8 +154,7 @@ hash_entry_alloc(pgssSharedState *pgss, pgssHashKey *key, int encoding)
|
||||
/* ... and don't forget the query text metadata */
|
||||
entry->encoding = encoding;
|
||||
}
|
||||
if (entry == NULL)
|
||||
elog(DEBUG1, "%s", "pg_stat_monitor: out of memory");
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user