From 36731d467e9495c4de8b3ea6f11af7e5e22e80f9 Mon Sep 17 00:00:00 2001 From: John Carr Date: Fri, 21 Aug 1992 03:02:54 +0000 Subject: [PATCH] Don't depend on behavior of malloc(0) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2352 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/asn.1/qbuf2data.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/krb5/asn.1/qbuf2data.c b/src/lib/krb5/asn.1/qbuf2data.c index f9e6de310..44afbd736 100644 --- a/src/lib/krb5/asn.1/qbuf2data.c +++ b/src/lib/krb5/asn.1/qbuf2data.c @@ -56,7 +56,13 @@ register int *error; if (!retval) { goto nomem; } - retval->length = val->qb_forw->qb_len; + /* If there is no data, don't call malloc. This saves space on systems + which allocate data in response to malloc(0), and saves error checking + on systems which return NULL. */ + if ((retval->length = val->qb_forw->qb_len) == 0) { + retval->data = 0; + return retval; + } retval->data = (char *)xmalloc(val->qb_forw->qb_len); if (!retval->data) { xfree(retval); -- 2.26.2