mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 01:18:00 +00:00
testsc: fix disorganised alloc/free in test_hash().
These tests also failed when I reran testsc, and looking at the code, no wonder: in each test iteration, the hash object is allocated _before_ logging begins, rather than after, so that its addresses aren't normalised by the test suite to 'n bytes after allocation #0'. So these tests only pass as long as all the allocations get lucky in reusing the same address. I guess we got lucky on all previous occasions and didn't notice until now. Easy fix: now each iteration does alloc / do stuff / free within the logged section.
This commit is contained in:
parent
c193fe9848
commit
4aa5d88fdb
@ -1567,6 +1567,7 @@ static void test_hash(const ssh_hashalg *halg)
|
||||
test_skipped = true;
|
||||
return;
|
||||
}
|
||||
ssh_hash_free(h);
|
||||
|
||||
size_t datalen = 256;
|
||||
uint8_t *data = snewn(datalen, uint8_t);
|
||||
@ -1576,16 +1577,14 @@ static void test_hash(const ssh_hashalg *halg)
|
||||
random_read(data, datalen);
|
||||
|
||||
log_start();
|
||||
h = ssh_hash_new(halg);
|
||||
put_data(h, data, datalen);
|
||||
ssh_hash_final(h, hash);
|
||||
log_end();
|
||||
|
||||
h = ssh_hash_new(halg);
|
||||
}
|
||||
|
||||
sfree(data);
|
||||
sfree(hash);
|
||||
ssh_hash_free(h);
|
||||
}
|
||||
|
||||
#define HASH_TESTFN(Y_unused, hash) \
|
||||
|
Loading…
Reference in New Issue
Block a user