Fix potential memory leaks and crashes.

This commit is contained in:
Jan Vidar Krey
2009-11-18 17:41:28 +01:00
parent f4e82ef503
commit 00995a1946
12 changed files with 97 additions and 27 deletions

View File

@@ -54,6 +54,11 @@ void list_clear(struct linked_list* list, void (*free_handle)(void* ptr))
void list_append(struct linked_list* list, void* data_ptr)
{
struct node* new_node = (struct node*) hub_malloc_zero(sizeof(struct node));
if (!new_node)
{
LOG_FATAL("Unable to allocate memory");
return;
}
new_node->ptr = data_ptr;
if (list->last)

View File

@@ -47,10 +47,13 @@ extern uint64_t tiger_sboxes[4*256];
ROUND(b, c, a, x7, mul)
void tiger_compress(uint64_t* str, uint64_t state[3]) {
uint64_t a, b, c, swap;
uint64_t a, b, c;
uint64_t x0, x1, x2, x3, x4, x5, x6, x7;
uint64_t aa, bb, cc;
#if PASSES > 3
uint64_t swap;
size_t pass_no;
#endif
a = state[0];
b = state[1];
c = state[2];
@@ -107,7 +110,8 @@ void tiger_compress(uint64_t* str, uint64_t state[3]) {
x7 -= x6 ^ 0x0123456789ABCDEFULL;
PASS(b, c, a, 9);
#if PASSES > 3
for (pass_no = 3; pass_no < PASSES; pass_no++)
{
x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5ULL;
@@ -134,7 +138,8 @@ void tiger_compress(uint64_t* str, uint64_t state[3]) {
c = b;
b = swap;
}
#endif
a ^= aa;
b -= bb;
c += cc;