From 30dbae2dbe42fe88b1dbdc3b0a3a80d5537697ec Mon Sep 17 00:00:00 2001 From: Gregory Nutt <gnutt@nuttx.org> Date: Thu, 21 Dec 2017 12:04:17 -0600 Subject: [PATCH] reopen should return NULL when oflags is less than 0, not equal to 0. Because negative value is returned on failure of lib_mode2offlags which converts the mode string into file open mode flag. --- libc/stdio/lib_freopen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/stdio/lib_freopen.c b/libc/stdio/lib_freopen.c index 830ea9a78f..0fffc1bd96 100644 --- a/libc/stdio/lib_freopen.c +++ b/libc/stdio/lib_freopen.c @@ -113,7 +113,7 @@ FAR FILE *freopen(FAR const char *path, FAR const char *mode, /* Convert the mode string into standard file open mode flags. */ oflags = lib_mode2oflags(mode); - if (oflags == 0) + if (oflags < 0) { return NULL; } -- GitLab