diff --git a/misc.c b/misc.c index d3a67f66..d40f9901 100644 --- a/misc.c +++ b/misc.c @@ -459,7 +459,7 @@ char *fgetline(FILE *fp) int size = 512, len = 0; while (fgets(ret + len, size - len, fp)) { len += strlen(ret + len); - if (ret[len-1] == '\n') + if (len > 0 && ret[len-1] == '\n') break; /* got a newline, we're done */ size = len + 512; ret = sresize(ret, size, char);