return;
}
- key->data = OICRealloc(key->data, ctx.buflen);
- if (NULL == key->data)
+ uint8_t *tmp = OICRealloc(key->data, ctx.buflen);
+ if (NULL == tmp)
{
+ OICFree(key->data);
+ key->data = NULL;
OIC_LOG(ERROR, TAG, "Failed to allocate memory");
mbedtls_pem_free(&ctx);
return;
}
+ key->data = tmp;
memcpy(key->data, ctx.buf, ctx.buflen);
key->len = ctx.buflen;
}
else if(temp->privateData.encoding == OIC_ENCODING_DER)
{
- key->data = OICRealloc(key->data, key->len + temp->privateData.len);
+ uint8_t *tmp = OICRealloc(key->data, key->len + temp->privateData.len);
+ if (NULL == tmp)
+ {
+ OICFree(key->data);
+ key->data = NULL;
+ OIC_LOG(ERROR, TAG, "Failed to allocate memory");
+ return;
+ }
+ key->data = tmp;
memcpy(key->data + key->len, temp->privateData.data, temp->privateData.len);
key->len += temp->privateData.len;
OIC_LOG_V(DEBUG, TAG, "Key for %s found", usage);
out->len = 0;
- out->data = OICRealloc(out->data, crl->len);
- if (out->data)
+ uint8_t *tmp = OICRealloc(out->data, crl->len);
+ if (tmp)
{
+ out->data = tmp;
memcpy(out->data, crl->data, crl->len);
out->len = crl->len;
}
else
{
+ OICFree(out->data);
+ out->data = NULL;
OIC_LOG(ERROR, TAG, "Can't allocate memory for out->data");
}
DeleteCrl(crlRes);