loolwsd: deallocates memory previously allocated by malloc

This commit is contained in:
Henry Castro
2016-05-25 00:32:00 -04:00
parent 0545001add
commit bf1a4705e4
2 changed files with 11 additions and 3 deletions

View File

@ -695,7 +695,10 @@ bool ChildSession::getCommandValues(const char* /*buffer*/, int /*length*/, Stri
if (_multiView)
_loKitDocument->setView(_viewId);
return sendTextFrame("commandvalues: " + std::string(_loKitDocument->getCommandValues(command.c_str())));
char* ptrValues = _loKitDocument->getCommandValues(command.c_str());
bool success = sendTextFrame("commandvalues: " + std::string(ptrValues));
std::free(ptrValues);
return success;
}
bool ChildSession::getPartPageRectangles(const char* /*buffer*/, int /*length*/)

View File

@ -107,6 +107,7 @@ namespace LOKitHelper
inline
std::string documentStatus(LibreOfficeKitDocument *loKitDocument)
{
char* ptrValue;
assert(loKitDocument && "null loKitDocument");
const auto type = static_cast<LibreOfficeKitDocumentType>(loKitDocument->pClass->getDocumentType(loKitDocument));
@ -128,11 +129,15 @@ namespace LOKitHelper
oss << "\n";
if (type == LOK_DOCTYPE_PRESENTATION)
{
oss << loKitDocument->pClass->getPartHash(loKitDocument, i);
ptrValue = loKitDocument->pClass->getPartHash(loKitDocument, i);
oss << ptrValue;
std::free(ptrValue);
}
else
{
oss << loKitDocument->pClass->getPartName(loKitDocument, i);
ptrValue = loKitDocument->pClass->getPartName(loKitDocument, i);
oss << ptrValue;
std::free(ptrValue);
}
}
}