Return from addrbook_load if a file is empty.
This commit is contained in:
parent
a2e0694efc
commit
d95b4c3089
@ -46,9 +46,12 @@ int addrbook_load(addrbook_t *ab, FILE *in) {
|
||||
char *line = NULL;
|
||||
size_t line_len = 0;
|
||||
size_t lines = 0;
|
||||
|
||||
while (getline(&line, &line_len, in) != -1)
|
||||
while (getline(&line, &line_len, in) != -1) {
|
||||
++lines;
|
||||
}
|
||||
|
||||
if (lines == 0)
|
||||
return -1;
|
||||
|
||||
if (ab->entries != NULL)
|
||||
free(ab->entries);
|
||||
|
Loading…
Reference in New Issue
Block a user