return OC_STACK_ERROR;
}
- OicSecCred_t *headCred = (OicSecCred_t *) OICCalloc(1, sizeof(OicSecCred_t));
+ OicSecCred_t *headCred = NULL;
// Enter CRED Root Map
CborValue CredRootMap = { .parser = NULL, .ptr = NULL, .remaining = 0, .extra = 0, .type = 0, .flags = 0 };
cborFindResult = cbor_value_enter_container(&credCbor, &CredRootMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Entering CRED Root Map.");
+ headCred = (OicSecCred_t *) OICCalloc(1, sizeof(OicSecCred_t));
+ VERIFY_NOT_NULL(TAG, headCred, ERROR);
+
while (cbor_value_is_valid(&CredRootMap))
{
char* tagName = NULL;
else
{
cred = (OicSecCred_t *) OICCalloc(1, sizeof(OicSecCred_t));
+ VERIFY_NOT_NULL(TAG, cred, ERROR);
OicSecCred_t *temp = headCred;
while (temp->next)
{
temp->next = cred;
}
- VERIFY_NOT_NULL(TAG, cred, ERROR);
-
while(cbor_value_is_valid(&credMap) && cbor_value_is_text_string(&credMap))
{
char* name = NULL;
ret = OC_STACK_OK;
exit:
- if ((CborErrorOutOfMemory == cborEncoderResult) && (cborLen < CBOR_MAX_SIZE))
- {
- // reallocate and try again!
- OICFree(outPayload);
- // Since the allocated initial memory failed, double the memory.
- cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
- cborEncoderResult = CborNoError;
- ret = CrlToCBORPayload(crl, payload, &cborLen, lastUpdate);
- }
-
if ((CborNoError != cborEncoderResult) || (OC_STACK_OK != ret))
{
OICFree(outPayload);
- outPayload = NULL;
- *payload = NULL;
- *size = 0;
- ret = OC_STACK_ERROR;
+ if ((CborErrorOutOfMemory == cborEncoderResult) && (cborLen < CBOR_MAX_SIZE))
+ {
+ // Since the allocated initial memory failed, double the memory.
+ cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
+ cborEncoderResult = CborNoError;
+ ret = CrlToCBORPayload(crl, payload, &cborLen, lastUpdate);
+ if (OC_STACK_OK != ret)
+ {
+ outPayload = NULL;
+ *payload = NULL;
+ *size = 0;
+ ret = OC_STACK_ERROR;
+ }
+ }
+ else
+ {
+ outPayload = NULL;
+ *payload = NULL;
+ *size = 0;
+ ret = OC_STACK_ERROR;
+ }
}
return ret;