]> git.ipfire.org Git - thirdparty/git.git/blobdiff - strbuf.c
strbuf_addch: avoid calling strbuf_grow
[thirdparty/git.git] / strbuf.c
index 88cafd4a70b8179a4e911c18704fb4ab0f2a21f5..af2bad4b561a0972e50b8dd9e04121ed09151896 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -443,12 +443,14 @@ int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int term)
                return EOF;
 
        strbuf_reset(sb);
-       while ((ch = fgetc(fp)) != EOF) {
+       flockfile(fp);
+       while ((ch = getc_unlocked(fp)) != EOF) {
                strbuf_grow(sb, 1);
                sb->buf[sb->len++] = ch;
                if (ch == term)
                        break;
        }
+       funlockfile(fp);
        if (ch == EOF && sb->len == 0)
                return EOF;