Skip to content

Commit 51ecdeb

Browse files
committed
now uses the correct realloc pattern with testing the reallocated pointer before assigning
1 parent d398576 commit 51ecdeb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

client/src/loclass/ikeys.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,15 @@ void invert_hash0(uint8_t k[8]) {
562562

563563
// Create new forks by duplicating existing uint64_t values
564564
int new_head = heads_count * 2;
565-
hydra_heads = (uint64_t *)realloc(hydra_heads, new_head * sizeof(uint64_t));
565+
566+
// proper realloc pattern
567+
uint64_t *ptmp = (uint64_t *)realloc(hydra_heads, new_head * sizeof(uint64_t));
568+
if (ptmp == NULL) {
569+
PrintAndLogEx(FAILED, "failed to allocate memory");
570+
free(hydra_heads);
571+
return;
572+
}
573+
hydra_heads = ptmp;
566574

567575
// Duplicate all current values and add the value to both original and new ones
568576
for (int i = 0; i < heads_count; i++) {

0 commit comments

Comments
 (0)