From 6f60e626842b595208ae7fe0d2c32a91cce1fb73 Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Fri, 29 Jun 2018 17:09:53 +0200 Subject: [PATCH] bugfix in tixiRenameElement --- src/tixiImpl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tixiImpl.c b/src/tixiImpl.c index cd9f5ac..7df14be 100644 --- a/src/tixiImpl.c +++ b/src/tixiImpl.c @@ -1657,6 +1657,7 @@ DLL_EXPORT ReturnCode tixiRenameElement(const TixiDocumentHandle handle, const char* oldName, const char* newName) { + char* elementPath = (char*) malloc( sizeof(char) *( strlen(parentPath) + strlen(oldName) + 2 ) ); xmlNodePtr parent = NULL; xmlNodePtr element = NULL; int retVal = 0; @@ -1670,12 +1671,12 @@ DLL_EXPORT ReturnCode tixiRenameElement(const TixiDocumentHandle handle, return INVALID_XPATH; } - char* elementPath = (char*) malloc( sizeof(char) *( strlen(parentPath) + strlen(oldName) + 2 ) ); elementPath[0] = '\0'; strcat(elementPath, parentPath); strcat(elementPath, "/"); strcat(elementPath, oldName); retVal = getNodePtrFromElementPath(handle, elementPath, &element); + free(elementPath); if (retVal != SUCCESS) { return retVal; }