diff options
author | John Carr <jfc@mit.edu> | 1992-08-21 03:02:54 +0000 |
---|---|---|
committer | John Carr <jfc@mit.edu> | 1992-08-21 03:02:54 +0000 |
commit | 36731d467e9495c4de8b3ea6f11af7e5e22e80f9 (patch) | |
tree | 5bb9a223a868dd88775cf9c537503eb6ec660859 /src/lib/krb5/asn.1 | |
parent | f4b5489d2792ffe247df4541294e23da87ed8a61 (diff) | |
download | krb5-36731d467e9495c4de8b3ea6f11af7e5e22e80f9.tar.gz krb5-36731d467e9495c4de8b3ea6f11af7e5e22e80f9.tar.xz krb5-36731d467e9495c4de8b3ea6f11af7e5e22e80f9.zip |
Don't depend on behavior of malloc(0)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2352 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/krb5/asn.1')
-rw-r--r-- | src/lib/krb5/asn.1/qbuf2data.c | 8 |
1 files changed, 7 insertions, 1 deletions
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); |