free line if getline errors
This commit is contained in:
parent
771680ac17
commit
170e69d096
1 changed files with 6 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
#include <ctype.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue