summaryrefslogtreecommitdiff
path: root/include/tools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-06-19 09:57:58 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-06-19 15:38:52 +0200
commit8df7447139b1171d8fd29f5d682b053df5936006 (patch)
tree29b966e34ac6ff5adf408b9c017670e17c389127 /include/tools
parent9b7a890fd59744459692d7f66402c6bdd25acec4 (diff)
asan: need to use malloc instead of new for tools::JsonWriter
because the LOK API expects memory returned from those calls to be malloc'ed Change-Id: If6fbfb60c433bd6e58bc90a9a90a90663e2e1c60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96676 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/tools')
-rw-r--r--include/tools/json_writer.hxx14
1 files changed, 7 insertions, 7 deletions
diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index c1438783de78..c0312f6c581d 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -11,7 +11,6 @@
#include <tools/toolsdllapi.h>
#include <rtl/ustring.hxx>
#include <algorithm>
-#include <memory>
/** Simple JSON encoder designed specifically for LibreOfficeKit purposes.
*
@@ -28,7 +27,7 @@ class TOOLS_DLLPUBLIC JsonWriter
friend class ScopedJsonWriterNode;
int mSpaceAllocated;
- std::unique_ptr<char[]> maBuffer;
+ char* mpBuffer;
int mStartNodeCount;
char* mPos;
bool mbFirstFieldInNode;
@@ -54,14 +53,15 @@ private:
inline void ensureSpace(int noMoreBytesRequired)
{
- int currentUsed = mPos - maBuffer.get();
+ int currentUsed = mPos - mpBuffer;
if (currentUsed + noMoreBytesRequired >= mSpaceAllocated)
{
auto newSize = std::max(mSpaceAllocated * 2, (currentUsed + noMoreBytesRequired) * 2);
- auto pNew = new char[newSize];
- memcpy(pNew, maBuffer.get(), currentUsed);
- maBuffer.reset(pNew);
- mPos = maBuffer.get();
+ char* pNew = static_cast<char*>(malloc(newSize));
+ memcpy(pNew, mpBuffer, currentUsed);
+ free(mpBuffer);
+ mpBuffer = pNew;
+ mPos = mpBuffer;
}
}
};