summaryrefslogtreecommitdiff
path: root/StdLib/LibC/Stdio/fgets.c
diff options
context:
space:
mode:
Diffstat (limited to 'StdLib/LibC/Stdio/fgets.c')
-rw-r--r--StdLib/LibC/Stdio/fgets.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/StdLib/LibC/Stdio/fgets.c b/StdLib/LibC/Stdio/fgets.c
index cf107ab867..cb07154ada 100644
--- a/StdLib/LibC/Stdio/fgets.c
+++ b/StdLib/LibC/Stdio/fgets.c
@@ -1,11 +1,11 @@
/** @file
Implementation of fgets as declared in <stdio.h>.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
+ http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -48,6 +48,7 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include "reentrant.h"
#include "local.h"
@@ -65,8 +66,10 @@ fgets(char *buf, int n, FILE *fp)
_DIAGASSERT(buf != NULL);
_DIAGASSERT(fp != NULL);
- if (n <= 0) /* sanity check */
+ if ((fp == NULL) || (n <= 0)) { /* sanity check */
+ errno = EINVAL;
return (NULL);
+ }
FLOCKFILE(fp);
_SET_ORIENTATION(fp, -1);