summaryrefslogtreecommitdiff
path: root/src/gl/getdelim.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2016-12-04 18:48:55 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2016-12-04 19:17:50 +0100
commit50e8ed9e742198c0952464b1a7d44a5e8b84aee3 (patch)
tree2b71f473f6ad8b216d8050a9061e3dee82526d21 /src/gl/getdelim.c
parent8f0bf2fc4bfa06a8f44300f57bb40f143687cb5b (diff)
downloadgnutls-50e8ed9e742198c0952464b1a7d44a5e8b84aee3.tar.gz
src gl: updatedtmp-remove-iconv
Diffstat (limited to 'src/gl/getdelim.c')
-rw-r--r--src/gl/getdelim.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gl/getdelim.c b/src/gl/getdelim.c
index 88258e556f..175d5c79c0 100644
--- a/src/gl/getdelim.c
+++ b/src/gl/getdelim.c
@@ -1,5 +1,5 @@
/* getdelim.c --- Implementation of replacement getdelim function.
- Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2015 Free Software
+ Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2016 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or
@@ -47,6 +47,16 @@
# define getc_maybe_unlocked(fp) getc_unlocked(fp)
#endif
+static void
+alloc_failed (void)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Avoid errno problem without using the realloc module; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#endif
+}
+
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
NULL), pointing to *N characters of space. It is realloc'ed as
@@ -74,6 +84,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
new_lineptr = (char *) realloc (*lineptr, *n);
if (new_lineptr == NULL)
{
+ alloc_failed ();
result = -1;
goto unlock_return;
}
@@ -111,6 +122,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
new_lineptr = (char *) realloc (*lineptr, needed);
if (new_lineptr == NULL)
{
+ alloc_failed ();
result = -1;
goto unlock_return;
}