summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/krb5/asn.1/qbuf2data.c8
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);