From 17136370d8fa16697e8e5fce8ae65c67197f4438 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 1 Mar 2020 23:23:01 +0100 Subject: [PATCH] hgfs: fix loadrevinfo() for empty log bug loadrevinfo() would fail on a empty log portion due to a bug in the previous commit. the loop is supposed to skip all bytes until we encounter a empty line. the loop starts at the beginning of a line so when we encounter a \n, we have to terminate, otherwise read bytes until we see \n (end of a line) and then read another and test the condition again. --- sys/src/cmd/hgfs/info.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/src/cmd/hgfs/info.c b/sys/src/cmd/hgfs/info.c index 0d4dbb974..53fbda936 100644 --- a/sys/src/cmd/hgfs/info.c +++ b/sys/src/cmd/hgfs/info.c @@ -45,18 +45,16 @@ loadrevinfo(Revlog *changelog, int rev) free(line); ri->logoff = Boffset(buf); - for(;;){ if((c = Bgetc(buf)) < 0) goto Error; - if(c == '\n'){ + if(c == '\n') + break; + do { if((c = Bgetc(buf)) < 0) goto Error; - if(c == '\n') - break; - } + } while(c != '\n'); } - ri->loglen = Boffset(buf) - ri->logoff - 1; line = Brdstr(buf, '\0', 1);