diff --git a/lib/libc/iconv/iconv.c b/lib/libc/iconv/iconv.c index b550059b9ae2..3821a29a40fe 100644 --- a/lib/libc/iconv/iconv.c +++ b/lib/libc/iconv/iconv.c @@ -1,4 +1,4 @@ -/* $NetBSD: iconv.c,v 1.9 2009/03/03 14:39:06 explorer Exp $ */ +/* $NetBSD: iconv.c,v 1.10 2009/03/03 15:42:43 explorer Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: iconv.c,v 1.9 2009/03/03 14:39:06 explorer Exp $"); +__RCSID("$NetBSD: iconv.c,v 1.10 2009/03/03 15:42:43 explorer Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -72,6 +72,11 @@ iconv_open(const char *out, const char *in) * blindly. */ out_truncated = strdup(out); + if (out_truncated == NULL) { + errno = ENOMEM; + return ((iconv_t)-1); + } + p = out_truncated; while (*p != '/' && *p != 0) p++;