Skip to content

Commit 797833d

Browse files
TheAssembler1github-actions[bot]jeanbez
authored
Fix seg fault when mercury initialization fails (#283)
* check for NULL paramterse in hash table * Committing clang-format changes --------- Co-authored-by: github-actions <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jean Luca Bez <[email protected]>
1 parent aabd25a commit 797833d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/commons/collections/pdc_hash_table.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,12 @@ unsigned int
542542
hash_table_num_entries(HashTable *hash_table)
543543
{
544544
FUNC_ENTER(NULL);
545+
546+
if (hash_table == NULL) {
547+
LOG_WARNING("hash_table was NULL\n");
548+
FUNC_LEAVE(0);
549+
};
550+
545551
FUNC_LEAVE(hash_table->entries);
546552
}
547553

@@ -552,6 +558,15 @@ hash_table_iterate(HashTable *hash_table, HashTableIterator *iterator)
552558

553559
unsigned int chain;
554560

561+
if (hash_table == NULL) {
562+
LOG_WARNING("hash_table was NULL\n");
563+
FUNC_LEAVE_VOID();
564+
}
565+
if (iterator == NULL) {
566+
LOG_WARNING("iterator was NULL\n");
567+
FUNC_LEAVE_VOID();
568+
}
569+
555570
iterator->hash_table = hash_table;
556571

557572
/* Default value of next if no entries are found. */

0 commit comments

Comments
 (0)