Skip to content

Commit

Permalink
fix memory buffer handling in TestPubKeyHex ref skycoin#34
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Denis committed May 28, 2019
1 parent af75a4b commit b5bf315
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/cgo/tests/check_cipher.crypto.common.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ START_TEST(TestPubKeyHex)
cipher__PubKey p, p2;
cipher__SecKey sk;
GoString s3, s4;
const char buff_s3[50];
unsigned int errorcode;

GoUint32 err = SKY_cipher_GenerateKeyPair(&p, &sk);
ck_assert(err == SKY_OK);
GoString_ tmp_s3 = {buff_s3, 0};
GoString_ tmp_s3;
err = SKY_cipher_PubKey_Hex(&p, &tmp_s3);
registerMemCleanup((void*)tmp_s3.p);
ck_assert(err == SKY_OK);
s3.n = tmp_s3.n;
s3.p = tmp_s3.p;
errorcode = SKY_cipher_PubKeyFromHex(s3, &p2);
ck_assert(errorcode == SKY_OK);
ck_assert(isPubKeyEq(&p, &p2));

char s4_buff[sizeof(cipher__PubKey) * 2];
GoString_ tmp_s4 = {s4_buff, 0};
GoString_ tmp_s4;
err = SKY_cipher_PubKey_Hex(&p2, &tmp_s4);
registerMemCleanup((void*)tmp_s4.p);
ck_assert(err == SKY_OK);
s4.n = tmp_s4.n;
s4.p = tmp_s4.p;
Expand Down

0 comments on commit b5bf315

Please sign in to comment.