X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Ffclose.c;h=38e8a1e39dae99255328d97150180652afde9fb2;hb=96fbcf7d80f469e39d1dd12533f8bb8d13b64fe5;hp=373a2c76cc5b71b872817bf4735c7369a6bc4f82;hpb=dba68bf98fc708cea4c478278c889fc7ad802b00;p=musl diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c index 373a2c76..38e8a1e3 100644 --- a/src/stdio/fclose.c +++ b/src/stdio/fclose.c @@ -3,9 +3,11 @@ int fclose(FILE *f) { int r; - int perm = f->flags & F_PERM; + int perm; + + FFINALLOCK(f); - if (!perm) { + if (!(perm = f->flags & F_PERM)) { OFLLOCK(); if (f->prev) f->prev->next = f->next; if (f->next) f->next->prev = f->prev; @@ -16,6 +18,7 @@ int fclose(FILE *f) r = fflush(f); r |= f->close(f); + if (f->getln_buf) free(f->getln_buf); if (!perm) free(f); return r;