If readfile() reads an empty file, fgets() won't truncate the buffer
and it'll still contain the contents of the previously read file.
[lh: fixed similar issue in ui-repolist.c]
Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
if (!(f = fopen(path, "r")))
return NULL;
if (!(f = fopen(path, "r")))
return NULL;
fgets(buf, MAX_PATH, f);
fclose(f);
return buf;
fgets(buf, MAX_PATH, f);
fclose(f);
return buf;
if (!(f = fopen(path, "r")))
return -1;
if (!(f = fopen(path, "r")))
return -1;
if (fgets(buf, sizeof(buf), f) == NULL)
return -1;
fclose(f);
if (fgets(buf, sizeof(buf), f) == NULL)
return -1;
fclose(f);