From 1eea3f0ab6fbccac3f276b7db7101ed57e6986ba Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 14 Jan 2018 11:48:35 +0000 Subject: Fix some memory or file descriptor leaks in test code. Also some missing return value checks for `fopen`. --- other/DHT_bootstrap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'other') diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index b715181a..0e95805d 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c @@ -146,8 +146,13 @@ int main(int argc, char *argv[]) #endif - FILE *file; - file = fopen("PUBLIC_ID.txt", "w"); + const char *const public_id_filename = "PUBLIC_ID.txt"; + FILE *file = fopen(public_id_filename, "w"); + + if (file == NULL) { + printf("Could not open file \"%s\" for writing. Exiting...\n", public_id_filename); + exit(1); + } for (i = 0; i < 32; i++) { printf("%02hhX", dht->self_public_key[i]); -- cgit v1.2.3