diff options
author | irungentoo <irungentoo@tox.im> | 2014-02-09 09:27:50 -0500 |
---|---|---|
committer | irungentoo <irungentoo@tox.im> | 2014-02-09 09:27:50 -0500 |
commit | c498c206ed8eb2bd24031ddbe10956ff8bc9a82d (patch) | |
tree | ca7ff20c531951eea055a93f7a9a7ad274fa57e5 /other/fun/sign.c | |
parent | 7f977f9ad2fd4fdbfc1aec2081909da38cf601e9 (diff) | |
parent | 3782213b6e2731a29110e940546aa8981efad08b (diff) |
Merge pull request #720 from nurupo/master
Fixed some memory leaks
Diffstat (limited to 'other/fun/sign.c')
-rw-r--r-- | other/fun/sign.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/other/fun/sign.c b/other/fun/sign.c index 423d974a..eaea9d6a 100644 --- a/other/fun/sign.c +++ b/other/fun/sign.c | |||
@@ -17,19 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | #include <sodium.h> | 18 | #include <sodium.h> |
19 | #include <string.h> | 19 | #include <string.h> |
20 | 20 | #include "../../testing/misc_tools.c" // hex_string_to_bin | |
21 | unsigned char *hex_string_to_bin(char hex_string[]) | ||
22 | { | ||
23 | size_t len = strlen(hex_string); | ||
24 | unsigned char *val = malloc(len); | ||
25 | char *pos = hex_string; | ||
26 | int i; | ||
27 | |||
28 | for (i = 0; i < len; ++i, pos += 2) | ||
29 | sscanf(pos, "%2hhx", &val[i]); | ||
30 | |||
31 | return val; | ||
32 | } | ||
33 | 21 | ||
34 | int load_file(char *filename, char **result) | 22 | int load_file(char *filename, char **result) |
35 | { | 23 | { |
@@ -90,6 +78,7 @@ int main(int argc, char *argv[]) | |||
90 | unsigned long long smlen; | 78 | unsigned long long smlen; |
91 | char *sm = malloc(size + crypto_sign_ed25519_BYTES * 2); | 79 | char *sm = malloc(size + crypto_sign_ed25519_BYTES * 2); |
92 | crypto_sign_ed25519(sm, &smlen, data, size, secret_key); | 80 | crypto_sign_ed25519(sm, &smlen, data, size, secret_key); |
81 | free(secret_key); | ||
93 | 82 | ||
94 | if (smlen - size != crypto_sign_ed25519_BYTES) | 83 | if (smlen - size != crypto_sign_ed25519_BYTES) |
95 | goto fail; | 84 | goto fail; |