diff --git a/modfetch.c b/modfetch.c index 68b0da9..fd24bdd 100644 --- a/modfetch.c +++ b/modfetch.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -140,6 +141,9 @@ Config parse_config(FILE *config_file) { .module_count = 0, }; + // TODO handle errors of all the function inside the while + errno = 0; + // TODO rewrite this to read the config char by char while ((read = getline(&line, &len, config_file)) != -1) { if (read <= 1) @@ -200,6 +204,8 @@ Config parse_config(FILE *config_file) { free(line); } + if (read == -1 && errno != 0) + free(line); return config; }