argon2: don't dereference a pointer before testing it for NULL

This commit is contained in:
Frank Denis 2015-12-29 22:22:54 +01:00
parent 77a61b8ad7
commit 28ca446f73
2 changed files with 6 additions and 2 deletions

View File

@ -109,7 +109,7 @@ void fill_segment_ref(const argon2_instance_t *instance,
uint32_t prev_offset, curr_offset;
uint32_t starting_index;
uint32_t i;
int data_independent_addressing = (instance->type == Argon2_i);
int data_independent_addressing;
/* Pseudo-random values that determine the reference block position */
uint64_t *pseudo_rands = NULL;
@ -117,6 +117,8 @@ void fill_segment_ref(const argon2_instance_t *instance,
return;
}
data_independent_addressing = (instance->type == Argon2_i);
pseudo_rands =
(uint64_t *)malloc(sizeof(uint64_t) * (instance->segment_length));

View File

@ -101,7 +101,7 @@ void fill_segment_ssse3(const argon2_instance_t *instance,
uint32_t prev_offset, curr_offset;
uint32_t starting_index, i;
__m128i state[64];
int data_independent_addressing = (instance->type == Argon2_i);
int data_independent_addressing;
/* Pseudo-random values that determine the reference block position */
uint64_t *pseudo_rands = NULL;
@ -110,6 +110,8 @@ void fill_segment_ssse3(const argon2_instance_t *instance,
return;
}
data_independent_addressing = (instance->type == Argon2_i);
pseudo_rands =
(uint64_t *)malloc(sizeof(uint64_t) * instance->segment_length);
if (pseudo_rands == NULL) {