Skip to content

Commit

Permalink
Avoid VLA in hash.h
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Feb 17, 2017
1 parent 12f46fa commit 5c8fd50
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class CHash256 {
static const size_t OUTPUT_SIZE = CSHA256::OUTPUT_SIZE;

void Finalize(unsigned char hash[OUTPUT_SIZE]) {
unsigned char buf[sha.OUTPUT_SIZE];
unsigned char buf[CSHA256::OUTPUT_SIZE];
sha.Finalize(buf);
sha.Reset().Write(buf, sha.OUTPUT_SIZE).Finalize(hash);
sha.Reset().Write(buf, CSHA256::OUTPUT_SIZE).Finalize(hash);
}

CHash256& Write(const unsigned char *data, size_t len) {
Expand All @@ -49,9 +49,9 @@ class CHash160 {
static const size_t OUTPUT_SIZE = CRIPEMD160::OUTPUT_SIZE;

void Finalize(unsigned char hash[OUTPUT_SIZE]) {
unsigned char buf[sha.OUTPUT_SIZE];
unsigned char buf[CSHA256::OUTPUT_SIZE];
sha.Finalize(buf);
CRIPEMD160().Write(buf, sha.OUTPUT_SIZE).Finalize(hash);
CRIPEMD160().Write(buf, CSHA256::OUTPUT_SIZE).Finalize(hash);
}

CHash160& Write(const unsigned char *data, size_t len) {
Expand Down

0 comments on commit 5c8fd50

Please sign in to comment.