Don't access line[-1] for a zero-length "line" from fgets.
[git/git.git] / server-info.c
index a051e49..c1c073b 100644 (file)
@@ -101,7 +101,7 @@ static int read_pack_info_file(const char *infofile)
 
        while (fgets(line, sizeof(line), fp)) {
                int len = strlen(line);
-               if (line[len-1] == '\n')
+               if (len && line[len-1] == '\n')
                        line[--len] = 0;
 
                if (!len)