correct locking in stdio functions that tried to be lock-free
[musl] / src / stdio / fwide.c
index f4da47f..4848068 100644 (file)
@@ -5,6 +5,8 @@
 
 int fwide(FILE *f, int mode)
 {
-       if (!f->mode) f->mode = NORMALIZE(mode);
-       return f->mode;
+       FLOCK(f);
+       if (!f->mode) mode = f->mode = NORMALIZE(mode);
+       FUNLOCK(f);
+       return mode;
 }