summaryrefslogtreecommitdiff
path: root/other/DHT_bootstrap.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-01-14 11:48:35 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-01-14 19:15:28 +0000
commit1eea3f0ab6fbccac3f276b7db7101ed57e6986ba (patch)
treeadc7316ebb8efa109935b49fdb6cce82990b8c8c /other/DHT_bootstrap.c
parentbacd74c4dd1fc6edaaacf580b20a9292f3322532 (diff)
Fix some memory or file descriptor leaks in test code.
Also some missing return value checks for `fopen`.
Diffstat (limited to 'other/DHT_bootstrap.c')
-rw-r--r--other/DHT_bootstrap.c9
1 files changed, 7 insertions, 2 deletions
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[])
146 146
147#endif 147#endif
148 148
149 FILE *file; 149 const char *const public_id_filename = "PUBLIC_ID.txt";
150 file = fopen("PUBLIC_ID.txt", "w"); 150 FILE *file = fopen(public_id_filename, "w");
151
152 if (file == NULL) {
153 printf("Could not open file \"%s\" for writing. Exiting...\n", public_id_filename);
154 exit(1);
155 }
151 156
152 for (i = 0; i < 32; i++) { 157 for (i = 0; i < 32; i++) {
153 printf("%02hhX", dht->self_public_key[i]); 158 printf("%02hhX", dht->self_public_key[i]);