--- libaitmqtt/src/pub.c 2012/04/27 15:49:07 1.1.1.1.2.4 +++ libaitmqtt/src/pub.c 2012/06/11 08:37:41 1.1.1.1.2.5 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: pub.c,v 1.1.1.1.2.4 2012/04/27 15:49:07 misho Exp $ +* $Id: pub.c,v 1.1.1.1.2.5 2012/06/11 08:37:41 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -207,7 +207,7 @@ mqtt_msgPUBCOMP(mqtt_msg_t * __restrict buf, u_short m * @psTopic = Topic * @topicLen = Topic length * @msgID = MessageID - * @pData = Data buffer + * @pData = Data buffer, may be NULL * return: -1 error or !=-1 allocated data buffer length */ int @@ -220,7 +220,7 @@ mqtt_readPUBLISH(mqtt_msg_t * __restrict buf, char * _ mqtt_len_t *v; caddr_t pos; - if (!buf || !psTopic || !msgID || !pData) + if (!buf || !psTopic || !msgID) return -1; hdr = _mqtt_readHEADER(buf, MQTT_TYPE_PUBLISH, &ret, &len); @@ -255,7 +255,7 @@ mqtt_readPUBLISH(mqtt_msg_t * __restrict buf, char * _ if (len < 0) { mqtt_SetErr(EINVAL, "Short message length %d", len); return -1; - } else { + } else if (pData) { if (!(*pData = malloc(len + 1))) { LOGERR; return -1;