- added checks for failed memory allocation

v1.6_develop_rgoose_sntp
Michael Zillgith 3 years ago
parent 4cacbe7c81
commit aa91961b41

@ -156,14 +156,14 @@ LinkedList_remove(LinkedList list, void* data)
LinkedList
LinkedList_insertAfter(LinkedList list, void* data)
{
LinkedList originalNextElement = LinkedList_getNext(list);
LinkedList newElement = LinkedList_create();
if (newElement) {
newElement->data = data;
newElement->next = originalNextElement;
newElement->next = LinkedList_getNext(list);
list->next = newElement;
}
return newElement;
}

@ -1,7 +1,7 @@
/*
* mms_file_service.c
*
* Copyright 2013-2018 Michael Zillgith
* Copyright 2013-2022 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -370,7 +370,6 @@ mmsServer_handleFileOpenRequest(
else
mmsMsg_createServiceErrorPdu(invokeId, response, MMS_ERROR_FILE_FILE_NON_EXISTENT);
}
else
mmsMsg_createServiceErrorPdu(invokeId, response, MMS_ERROR_RESOURCE_OTHER);
@ -390,7 +389,6 @@ exit_reject_invalid_pdu:
#if (MMS_OBTAIN_FILE_SERVICE == 1)
static void /* Confirmed service error (ServiceError) */
createServiceErrorObtainFileError(uint32_t invokeId, ByteBuffer* response,
MmsError errorType, uint32_t value)
@ -403,7 +401,6 @@ createServiceErrorObtainFileError(uint32_t invokeId, ByteBuffer* response,
buffer, size);
}
static void
createObtainFileResponse(uint32_t invokeId, ByteBuffer* response)
{
@ -1176,7 +1173,8 @@ mmsServer_handleFileDirectoryRequest(
char* continueAfter = NULL;
while (bufPos < maxBufPos) {
while (bufPos < maxBufPos)
{
uint8_t tag = buffer[bufPos++];
int length;
@ -1215,8 +1213,6 @@ mmsServer_handleFileDirectoryRequest(
mmsMsg_createMmsRejectPdu(&invokeId, MMS_ERROR_REJECT_INVALID_PDU, response);
return;
}
}
int maxPduSize = connection->maxPduSize;

@ -1,7 +1,7 @@
/*
* mms_get_namelist_service.c
*
* Copyright 2013, 2014, 2015 Michael Zillgith
* Copyright 2013-2022 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -109,6 +109,8 @@ appendMmsSubVariable(char* name, char* child)
char* newName = (char*) GLOBAL_MALLOC(newSize);
if (newName)
{
int bufPos = 0;
int i;
for (i = 0; i < nameLen; i++) {
@ -121,6 +123,7 @@ appendMmsSubVariable(char* name, char* child)
}
newName[bufPos] = 0;
}
return newName;
}
@ -139,6 +142,8 @@ addSubNamedVaribleNamesToList(LinkedList nameList, char* prefix, MmsVariableSpec
#if (CONFIG_MMS_SORT_NAME_LIST == 1)
int* index = (int*) GLOBAL_MALLOC(sizeof(int) * variable->typeSpec.structure.elementCount);
if (index)
{
for (i = 0; i < variable->typeSpec.structure.elementCount; i++)
index[i] = i;
@ -152,6 +157,8 @@ addSubNamedVaribleNamesToList(LinkedList nameList, char* prefix, MmsVariableSpec
char* variableName = appendMmsSubVariable(prefix, variables[i]->name);
#endif /* (CONFIG_MMS_SORT_NAME_LIST == 1) */
if (variableName)
{
listElement = LinkedList_insertAfter(listElement, variableName);
#if (CONFIG_MMS_SORT_NAME_LIST == 1)
@ -160,9 +167,12 @@ addSubNamedVaribleNamesToList(LinkedList nameList, char* prefix, MmsVariableSpec
listElement = addSubNamedVaribleNamesToList(listElement, variableName, variables[i]);
#endif /* (CONFIG_MMS_SORT_NAME_LIST == 1) */
}
}
#if (CONFIG_MMS_SORT_NAME_LIST == 1)
GLOBAL_FREEMEM(index);
}
#endif
}

Loading…
Cancel
Save