diff --git a/dongle.c b/dongle.c index f27aa960ef069b4dc9e81c9ea7f20a3d57846b4c..9f7747717f2f98635cee4c285b886509edbd4637 100644 --- a/dongle.c +++ b/dongle.c @@ -310,15 +310,15 @@ char *get_usb_stat(char *path, char *file) f = fopen(stat_path, "r"); if (!f) { perror("fopen"); - goto fail; + goto fail_fopen; } fgets(contents, 1024, f); remove_newline(contents); - fclose(f); + fclose(f); return strdup(contents); -fail: +fail_fopen: return NULL; } @@ -509,6 +509,7 @@ int get_devices(void) add_device(dev); } + closedir(dir); return 0; fail_dev: @@ -535,6 +536,7 @@ char *get_device_ip(char *device_name) perror("malloc"); goto fail_route; } + memset(route, 0, 1024); while ((fgets(route, 1024, fp)) != NULL) { remove_newline(route);