From 8515d6a51094c12cd6429df7e9ee2ea9b3c23c5f Mon Sep 17 00:00:00 2001 From: mid Date: Fri, 1 Sep 2000 00:19:52 +0000 Subject: [PATCH] - Fri Sep 1 00:13:04 UTC 2000 - Avoid zero-length mallocs in aim_tlv --- aim_tlv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aim_tlv.c b/aim_tlv.c index ee260b0..1e89318 100644 --- a/aim_tlv.c +++ b/aim_tlv.c @@ -45,9 +45,11 @@ struct aim_tlvlist_t *aim_readtlvchain(u_char *buf, int maxlen) cur->tlv = aim_createtlv(); cur->tlv->type = type; - cur->tlv->length = length; - cur->tlv->value = (u_char *)malloc(length*sizeof(u_char)); - memcpy(cur->tlv->value, buf+pos, length); + cur->tlv->length = length; + if (length) { + cur->tlv->value = (unsigned char *)malloc(length); + memcpy(cur->tlv->value, buf+pos, length); + } cur->next = list; list = cur; -- 2.45.2