Check for NULL return from strdup()

This commit is contained in:
explorer 2009-03-03 15:42:43 +00:00
parent 9a3995e433
commit 31c448a301

View File

@ -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 <sys/cdefs.h>
#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++;