1
0
Fork 0

Return from addrbook_load if a file is empty.

This commit is contained in:
Alexander Andreev 2024-03-28 18:03:41 +04:00
parent a2e0694efc
commit d95b4c3089
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34
1 changed files with 5 additions and 2 deletions

View File

@ -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);