From: John Carr Date: Fri, 21 Aug 1992 03:02:54 +0000 (+0000) Subject: Don't depend on behavior of malloc(0) X-Git-Tag: krb5-1.0-beta2~110 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=36731d467e9495c4de8b3ea6f11af7e5e22e80f9;p=krb5.git Don't depend on behavior of malloc(0) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2352 dc483132-0cff-0310-8789-dd5450dbe970 --- 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);