Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2613)

Unified Diff: Source/wtf/text/StringImpl.cpp

Issue 23901002: [blink]: Annotate StringImpl::createStatic leak for LeakSanitizer. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: First patch in set of patches to enable annotating known leaks in blink. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/wtf/text/StringImpl.cpp
diff --git a/Source/wtf/text/StringImpl.cpp b/Source/wtf/text/StringImpl.cpp
index f4ff9a4053596360ca71dbc563f29ff5117c5d23..a3bf6e1ce3ca044b4313c4424cb1db85655a10f6 100644
--- a/Source/wtf/text/StringImpl.cpp
+++ b/Source/wtf/text/StringImpl.cpp
@@ -25,6 +25,7 @@
#include "config.h"
#include "wtf/text/StringImpl.h"
+#include "wtf/LeakAnnotations.h"
#include "wtf/StdLibExtras.h"
#include "wtf/text/AtomicString.h"
#include "wtf/text/StringBuffer.h"
@@ -345,11 +346,14 @@ StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsign
// heap allocation from this call.
RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(LChar)));
size_t size = sizeof(StringImpl) + length * sizeof(LChar);
- StringImpl* impl = static_cast<StringImpl*>(fastMalloc(size));
-
- LChar* data = reinterpret_cast<LChar*>(impl + 1);
- impl = new (NotNull, impl) StringImpl(length, hash, StaticString);
- memcpy(data, string, length * sizeof(LChar));
+ StringImpl* impl;
+ {
+ WTF_ANNOTATE_SCOPED_MEMORY_LEAK;
+ impl = static_cast<StringImpl*>(fastMalloc(size));
+ LChar* data = reinterpret_cast<LChar*>(impl + 1);
+ impl = new (NotNull, impl) StringImpl(length, hash, StaticString);
+ memcpy(data, string, length * sizeof(LChar));
+ }
#ifndef NDEBUG
impl->assertHashIsCorrect();
#endif

Powered by Google App Engine
This is Rietveld 408576698