]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Stdio/ungetc.c
Add device abstraction code for the UEFI Console and UEFI Shell-based file systems.
[mirror_edk2.git] / StdLib / LibC / Stdio / ungetc.c
index e9d3807fcb63e5d41c76a08583581267d87d0b39..d8e1f3afc61acef871bf3bd99280a95ea94b19fb 100644 (file)
@@ -1,11 +1,11 @@
 /** @file\r
     Implementation of ungetc as declared in <stdio.h>.\r
 \r
-    Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+    Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
     This program and the accompanying materials are licensed and made available\r
     under the terms and conditions of the BSD License that accompanies this\r
     distribution.  The full text of the license may be found at\r
-    http://opensource.org/licenses/bsd-license.php.\r
+    http://opensource.org/licenses/bsd-license.\r
 \r
     THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
     WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
@@ -67,6 +67,10 @@ __submore(FILE *fp)
   unsigned char *p;\r
 \r
   _DIAGASSERT(fp != NULL);\r
+  if(fp == NULL) {\r
+    errno = EINVAL;\r
+    return (EOF);\r
+  }\r
 \r
   if (_UB(fp)._base == fp->_ubuf) {\r
     /*\r
@@ -98,6 +102,10 @@ int
 ungetc(int c, FILE *fp)\r
 {\r
   _DIAGASSERT(fp != NULL);\r
+  if(fp == NULL) {\r
+    errno = EINVAL;\r
+    return (EOF);\r
+  }\r
 \r
   if (c == EOF)\r
     return (EOF);\r