Skip to content

Commit

Permalink
Fix Memory Explode - Add free(job)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed May 8, 2021
1 parent a554946 commit b916019
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/sha1/Ducos1a_sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ class Ducos1a_sha1
// DUCO-S1 algorithm implementation for AVR boards (DUCO-S1A)
// Difficulty loop
int ducos1res = 0;
for (int ducos1res = 0; ducos1res < difficulty * 100 + 1; ducos1res++)
for (int ducos = 0; ducos < difficulty * 100 + 1; ducos++)
{
Sha1.init();
Sha1.print(lastblockhash + ducos1res);
Sha1.print(lastblockhash + ducos);
// Get SHA1 result
uint8_t *hash_bytes = Sha1.result();

if (memcmp(hash_bytes, job, sizeof(hash_bytes)) == 0)
{
// If expected hash is equal to the found hash, return the result
return ducos1res;
ducos1res = ducos;
break;
}
}
return 0;
free( job );
return ducos1res;
}
};

Expand Down

0 comments on commit b916019

Please sign in to comment.