From 90bdf763537815a523d0dbe75a67e7f0b14b0d9e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 27 Apr 2016 13:24:09 -0700 Subject: do not leak in IStringSet --- src/emscripten-optimizer/istring.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/emscripten-optimizer/istring.h') diff --git a/src/emscripten-optimizer/istring.h b/src/emscripten-optimizer/istring.h index 149f77d23..e47361eeb 100644 --- a/src/emscripten-optimizer/istring.h +++ b/src/emscripten-optimizer/istring.h @@ -149,11 +149,13 @@ namespace cashew { // IStringSet class IStringSet : public std::unordered_set { + std::vector data; public: IStringSet() {} IStringSet(const char *init) { // comma-delimited list int size = strlen(init) + 1; - char *curr = new char[size]; // leaked! + data.resize(size); + char *curr = &data[0]; strncpy(curr, init, size); while (1) { char *end = strchr(curr, ' '); -- cgit v1.2.3