Closed mashomee closed 5 years ago
version is 1.3.3
from #6 0x000000000062d651 in LinkedList_getNext (list=0x0) at src/common/linked_list.c:172
,
we can see the list is nullptr,
perhapes the entries
should be checked if it's nullptr.
LinkedList /* <char*> */
IedConnection_getDataSetDirectory(IedConnection self, IedClientError* error, const char* dataSetReference, bool* isDeletable)
{
bool deletable = false;
LinkedList dataSetMembers = NULL;
char domainIdBuffer[65];
char itemIdBuffer[DATA_SET_MAX_NAME_LENGTH + 1];
const char* domainId = NULL;
const char* itemId = NULL;
bool isAssociationSpecific = false;
if (dataSetReference[0] != '@') {
if ((dataSetReference[0] == '/') || (strchr(dataSetReference, '/') == NULL)) {
domainId = NULL;
if (dataSetReference[0] == '/')
itemId = dataSetReference + 1;
else
itemId = dataSetReference;
}
else {
domainId = MmsMapping_getMmsDomainFromObjectReference(dataSetReference, domainIdBuffer);
if (domainId == NULL) {
*error = IED_ERROR_OBJECT_REFERENCE_INVALID;
goto exit_function;
}
const char* itemIdRef = dataSetReference + strlen(domainId) + 1;
if (strlen(itemIdRef) > DATA_SET_MAX_NAME_LENGTH) {
*error = IED_ERROR_OBJECT_REFERENCE_INVALID;
goto exit_function;
}
char* itemIdRefInBuffer = StringUtils_copyStringToBuffer(itemIdRef, itemIdBuffer);
StringUtils_replace(itemIdRefInBuffer, '.', '$');
itemId = itemIdRefInBuffer;
}
}
else {
itemId = dataSetReference + 1;
isAssociationSpecific = true;
}
MmsError mmsError;
LinkedList entries;
if (isAssociationSpecific)
entries = MmsConnection_readNamedVariableListDirectoryAssociationSpecific(self->connection,
&mmsError, itemId, &deletable);
else
entries = MmsConnection_readNamedVariableListDirectory(self->connection,
&mmsError, domainId, itemId, &deletable);
if (mmsError == MMS_ERROR_NONE) {
LinkedList entry = LinkedList_getNext(entries);
dataSetMembers = LinkedList_create();
while (entry != NULL) {
MmsVariableAccessSpecification* varAccessSpec = (MmsVariableAccessSpecification*) entry->data;
char* objectReference = MmsMapping_varAccessSpecToObjectReference(varAccessSpec);
LinkedList_add(dataSetMembers, objectReference);
entry = LinkedList_getNext(entry);
}
if (isDeletable != NULL)
*isDeletable = deletable;
LinkedList_destroyDeep(entries, (LinkedListValueDeleteFunction) MmsVariableAccessSpecification_destroy);
}
*error = iedConnection_mapMmsErrorToIedError(mmsError);
exit_function:
return dataSetMembers;
}
It is possible that this problem can happen when the client parser thinks that the server sent and invalid response. I added some additional checks to catch this case. Please check the latest patch if it solves your problem.
Thanks.
Seems like that patch fixes this. Thanks again.
below is the sample code and stacktrace. Sometimes when i use
IedConnection_getDataSetDirectory
to get dataset entry, i'll crash.stacktrace:
What's bothering me is that it not always crashes.