From dbaf37cf8373d36e8b00c82ef180d5144523b33c Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 25 Feb 2000 19:52:27 +0000 Subject: [PATCH] Fri Feb 25 14:50:50 2000 Jeff Johnston * libc/stdio/flags.c (__sflags): Added check that mode[1] is non-null before looking at mode[2]. --- newlib/ChangeLog | 5 +++++ newlib/libc/stdio/flags.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 6adf4f4d8..2e39d2b07 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 25 14:50:50 2000 Jeff Johnston + + * libc/stdio/flags.c (__sflags): Added check that mode[1] + is non-null before looking at mode[2]. + Thu Feb 24 11:43:00 2000 Ran Cabell * libm/mathfp/sf_atan2.c: Fix atan2 typo for _DOUBLE_IS_32_BITS. diff --git a/newlib/libc/stdio/flags.c b/newlib/libc/stdio/flags.c index 6d62bd5bc..e448cca80 100644 --- a/newlib/libc/stdio/flags.c +++ b/newlib/libc/stdio/flags.c @@ -61,19 +61,19 @@ __sflags (ptr, mode, optr) ptr->_errno = EINVAL; return (0); } - if (mode[1] == '+' || mode[2] == '+') + if (mode[1] && (mode[1] == '+' || mode[2] == '+')) { ret = __SRW; m = O_RDWR; } - if (mode[1] == 'b' || mode[2] == 'b') + if (mode[1] && (mode[1] == 'b' || mode[2] == 'b')) { #ifdef O_BINARY m |= O_BINARY; #endif } #ifdef __CYGWIN__ - else if (mode[1] == 't' || mode[2] == 't') + else if (mode[1] && (mode[1] == 't' || mode[2] == 't')) #else else #endif -- 2.43.5