clone->info.token = temp;
}
- if (rep->info.options != NULL)
+ if (rep->info.options != NULL && rep->info.numOptions > 0)
{
// save the options
- clone->info.options = (CAHeaderOption_t *) OICMalloc(sizeof(CAHeaderOption_t));
+ clone->info.options =
+ (CAHeaderOption_t *) OICMalloc(sizeof(CAHeaderOption_t) * clone->info.numOptions);
if (clone->info.options == NULL)
{
OIC_LOG(DEBUG, TAG, "CACloneRequestInfo Out of memory");
OICFree(clone);
return NULL;
}
- memset(clone->info.options, 0, sizeof(CAHeaderOption_t));
- memcpy(clone->info.options, rep->info.options, sizeof(CAHeaderOption_t));
+ memcpy(clone->info.options,
+ rep->info.options,
+ sizeof(CAHeaderOption_t) * clone->info.numOptions);
}
if (rep->info.payload != NULL)