fix: mem leaks.

This commit is contained in:
iceman1001 2019-02-21 15:34:31 +01:00
commit 91d6836a47
7 changed files with 22 additions and 14 deletions

View file

@ -311,6 +311,11 @@ bool brute_force_bs(float *bf_rate, statelist_t *candidates, uint32_t cuid, uint
uint64_t start_time = msclock();
#if defined(__linux__) || defined(__APPLE__)
if ( NUM_BRUTE_FORCE_THREADS < 0 )
return false;
#endif
pthread_t threads[NUM_BRUTE_FORCE_THREADS];
struct args {
bool silent;
@ -322,7 +327,7 @@ bool brute_force_bs(float *bf_rate, statelist_t *candidates, uint32_t cuid, uint
uint8_t *best_first_bytes;
} thread_args[NUM_BRUTE_FORCE_THREADS];
for(uint32_t i = 0; i < NUM_BRUTE_FORCE_THREADS; i++){
for (uint32_t i = 0; i < NUM_BRUTE_FORCE_THREADS; i++){
thread_args[i].thread_ID = i;
thread_args[i].silent = silent;
thread_args[i].cuid = cuid;
@ -332,7 +337,7 @@ bool brute_force_bs(float *bf_rate, statelist_t *candidates, uint32_t cuid, uint
thread_args[i].best_first_bytes = best_first_bytes;
pthread_create(&threads[i], NULL, crack_states_thread, (void*)&thread_args[i]);
}
for(uint32_t i = 0; i < NUM_BRUTE_FORCE_THREADS; i++){
for (uint32_t i = 0; i < NUM_BRUTE_FORCE_THREADS; i++){
pthread_join(threads[i], 0);
}