git » libfiu » commit ad14b3c

preload/posix: Decrement recursion counter in ferror() wrapper

author Alberto Bertogli
2018-09-30 21:38:47 UTC
committer Alberto Bertogli
2018-09-30 22:21:54 UTC
parent 1f41f72b59f43889afe70717976e6aabf4ff5524

preload/posix: Decrement recursion counter in ferror() wrapper

The ferror() wrapper is not implemented fully via the macros, and it has
a bug where, under some conditions, the internal recursion counter would
not be decreased, causing the library to never fail anything after it.

This patch fixes the bug by adjusting the logic to always decrease the
recursion counter.

preload/posix/modules/posix.custom.c +1 -1

diff --git a/preload/posix/modules/posix.custom.c b/preload/posix/modules/posix.custom.c
index 9088b69..cc5e89a 100644
--- a/preload/posix/modules/posix.custom.c
+++ b/preload/posix/modules/posix.custom.c
@@ -322,7 +322,7 @@ int ferror (FILE *stream)
 
 	if (r == 0 && get_ferror(stream)) {
 		printd("ferror fixed\n");
-		return 1;
+		r = 1;
 	}
 
 exit: