Skip to content

Commit

Permalink
Fix a possible crash in hash.c
Browse files Browse the repository at this point in the history
  • Loading branch information
paraboul committed May 25, 2011
1 parent d9d59b4 commit 358ea62
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ void hashtbl_append(HTBL *htbl, const char *key, void *structaddr)
hTmp->next = NULL;
hTmp->lnext = htbl->first;
hTmp->lprev = NULL;

if (htbl->first != NULL) {
htbl->first->lprev = hTmp;
}

hTmp->key = xmalloc(sizeof(char) * (key_len+1));

Expand All @@ -112,6 +108,7 @@ void hashtbl_append(HTBL *htbl, const char *key, void *structaddr)
free(hTmp->key);
free(hTmp);
hDbl->addrs = (void *)structaddr;

return;
} else {
hDbl = hDbl->next;
Expand All @@ -120,6 +117,10 @@ void hashtbl_append(HTBL *htbl, const char *key, void *structaddr)
hTmp->next = htbl->table[key_hash];
}

if (htbl->first != NULL) {
htbl->first->lprev = hTmp;
}

htbl->first = hTmp;

htbl->table[key_hash] = hTmp;
Expand Down

0 comments on commit 358ea62

Please sign in to comment.