Some messages like ACKs, RESETs and others have null payload.
strlen was called in the function args which caused a seg fault.
Added check for null before calling strlen and moved call outside of
args list.
Change-Id: Ia97d48e662c220f73eec56bd260ed1f6c94dab90
Signed-off-by: Mandeep Shetty <mandeep.shetty@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/979
Reviewed-by: Erich Keane <erich.keane@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
coap_delete_list(optlist);
return NULL;
}
-
- pdu = CAGeneratePDUImpl((code_t) code, optlist, info, info.payload, strlen(info.payload));
+ size_t lenPayload = info.payload ? strlen(info.payload) : 0;
+ pdu = CAGeneratePDUImpl((code_t) code, optlist, info, info.payload, lenPayload);
if (NULL == pdu)
{
OIC_LOG(ERROR, TAG, "pdu NULL");