about summary refs log tree commit diff
path: root/iconv/iconv_close.c
diff options
context:
space:
mode:
Diffstat (limited to 'iconv/iconv_close.c')
-rw-r--r--iconv/iconv_close.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/iconv/iconv_close.c b/iconv/iconv_close.c
index d3123e21d8..ccd9d5f3ad 100644
--- a/iconv/iconv_close.c
+++ b/iconv/iconv_close.c
@@ -18,6 +18,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <errno.h>
 #include <iconv.h>
 
 #include <gconv.h>
@@ -26,5 +27,11 @@
 int
 iconv_close (iconv_t cd)
 {
+  if (cd == (iconv_t *) -1L)
+    {
+      __set_errno (EBADF);
+      return -1;
+    }
+
   return __gconv_close ((gconv_t) cd) ? -1 : 0;
 }