From 0b6806d7f74aca0273e41187d73685bd84eedd28 Mon Sep 17 00:00:00 2001 From: charmlesscoin Date: Sun, 4 Aug 2013 04:29:32 -0400 Subject: Removed memory leak, thanks to diath for spotting it. --- testing/misc_tools.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'testing/misc_tools.c') diff --git a/testing/misc_tools.c b/testing/misc_tools.c index dbaa8b3b..08f57588 100644 --- a/testing/misc_tools.c +++ b/testing/misc_tools.c @@ -36,5 +36,7 @@ unsigned char * hex_string_to_bin(char hex_string[]) int i; for(i = 0; i < len; ++i, pos+=2) sscanf(pos,"%2hhx",&val[i]); + + free(val); return val; } -- cgit v1.2.3 From ae8367dc3ee5652a9b10e178ac269cd5cba8797a Mon Sep 17 00:00:00 2001 From: charmlesscoin Date: Sun, 4 Aug 2013 05:09:12 -0400 Subject: whoops, returning a free'd variable is really not what I meant... --- testing/misc_tools.c | 1 - testing/nTox.c | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'testing/misc_tools.c') diff --git a/testing/misc_tools.c b/testing/misc_tools.c index 08f57588..aa546a88 100644 --- a/testing/misc_tools.c +++ b/testing/misc_tools.c @@ -37,6 +37,5 @@ unsigned char * hex_string_to_bin(char hex_string[]) for(i = 0; i < len; ++i, pos+=2) sscanf(pos,"%2hhx",&val[i]); - free(val); return val; } diff --git a/testing/nTox.c b/testing/nTox.c index 15e209a9..9a07ecdc 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -142,7 +142,9 @@ void line_eval(char *line) for (i = 0; i < 128; i++) temp_id[i] = line[i+prompt_offset]; - int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); + unsigned char *bin_string = hex_string_to_bin(temp_id); + int num = m_addfriend(bin_string, (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); + free(bin_string); char numstring[100]; switch (num) { case -1: @@ -456,7 +458,9 @@ int main(int argc, char *argv[]) else exit(1); - DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); + unsigned char *binary_string = hex_string_to_bin(argv[3]); + DHT_bootstrap(bootstrap_ip_port, binary_string); + free(binary_string); nodelay(stdscr, TRUE); while(true) { if (on == 0 && DHT_isconnected()) { -- cgit v1.2.3