diff --git a/arangod/VocBase/document-collection.c b/arangod/VocBase/document-collection.c index 2f74b1a492..0abe9c3fdc 100755 --- a/arangod/VocBase/document-collection.c +++ b/arangod/VocBase/document-collection.c @@ -3097,6 +3097,11 @@ static TRI_index_t* CreateCapConstraintDocumentCollection (TRI_document_collecti // create a new index idx = TRI_CreateCapConstraint(&sim->base, size); + if (idx == NULL) { + TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY); + + return NULL; + } if (iid) { idx->_iid = iid; diff --git a/arangod/VocBase/index.c b/arangod/VocBase/index.c index 24071e7fb8..0a18959f46 100755 --- a/arangod/VocBase/index.c +++ b/arangod/VocBase/index.c @@ -346,11 +346,16 @@ static TRI_json_t* JsonCapConstraint (TRI_index_t* idx, TRI_primary_collection_t } // create json object and fill it - json = TRI_CreateArrayJson(TRI_CORE_MEM_ZONE); + json = TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE); + if (json == NULL) { + TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY); - TRI_Insert3ArrayJson(TRI_CORE_MEM_ZONE, json, "id", TRI_CreateNumberJson(TRI_CORE_MEM_ZONE, idx->_iid)); - TRI_Insert3ArrayJson(TRI_CORE_MEM_ZONE, json, "type", TRI_CreateStringCopyJson(TRI_CORE_MEM_ZONE, "cap")); - TRI_Insert3ArrayJson(TRI_CORE_MEM_ZONE, json, "size", TRI_CreateNumberJson(TRI_CORE_MEM_ZONE, cap->_size)); + return NULL; + } + + TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "id", TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, idx->_iid)); + TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "type", TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, "cap")); + TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "size", TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, cap->_size)); return json; } @@ -424,7 +429,12 @@ TRI_index_t* TRI_CreateCapConstraint (struct TRI_primary_collection_s* collectio size_t size) { TRI_cap_constraint_t* cap; - cap = TRI_Allocate(TRI_CORE_MEM_ZONE, sizeof(TRI_cap_constraint_t), false); + cap = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_cap_constraint_t), false); + if (cap == NULL) { + TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY); + + return NULL; + } cap->base._iid = TRI_NewTickVocBase(); cap->base._type = TRI_IDX_TYPE_CAP_CONSTRAINT; @@ -461,7 +471,7 @@ void TRI_DestroyCapConstraint (TRI_index_t* idx) { void TRI_FreeCapConstraint (TRI_index_t* idx) { TRI_DestroyCapConstraint(idx); - TRI_Free(TRI_CORE_MEM_ZONE, idx); + TRI_Free(TRI_UNKNOWN_MEM_ZONE, idx); } //////////////////////////////////////////////////////////////////////////////// @@ -3171,6 +3181,7 @@ static TRI_json_t* JsonSkiplistIndex (TRI_index_t* idx, TRI_primary_collection_t path = collection->_shaper->lookupAttributePathByPid(collection->_shaper, shape); if (path == NULL) { TRI_Free(TRI_UNKNOWN_MEM_ZONE, fieldList); + return NULL; } fieldList[j] = ((const char*) path) + sizeof(TRI_shape_path_t) + path->_aidLength * sizeof(TRI_shape_aid_t); @@ -3181,8 +3192,9 @@ static TRI_json_t* JsonSkiplistIndex (TRI_index_t* idx, TRI_primary_collection_t // create json object and fill it // .......................................................................... json = TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE); - if (!json) { + if (json == NULL) { TRI_Free(TRI_UNKNOWN_MEM_ZONE, fieldList); + return NULL; }