Reviewers: bashi1, dgozman
CL:
https://codereview.chromium.org/2004423007/Message:
Meant to be a P0-bug fixer.
bashi-san, could you take a look as a third_party/WebKit/Source/bindings OWNER?
Description:
SourceLocation: Fix use-after-move.
Depending on the arguments evaluation order, the previous code may access
std::move'ed object. It is triggering crashes in many pages
including
google.com on Chrome OS (built by gcc).
BUG=614900
TEST=Manually verified new tab page doesn't crash (which previously did.)
Base URL:
https://chromium.googlesource.com/chromium/src.git@masterAffected files (+8, -4 lines):
M third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
Index: third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp b/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
index f7e4197f4b94008753555589c481ea87de5ecacc..c806cf2a0ab609b14bf1862d1a30a82c0134ecea 100644
--- a/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
@@ -41,8 +41,10 @@ std::unique_ptr<V8StackTrace> captureStackTrace()
PassOwnPtr<SourceLocation> SourceLocation::capture(const String& url, unsigned lineNumber, unsigned columnNumber)
{
std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace();
- if (stackTrace && !stackTrace->isEmpty())
- return SourceLocation::create(stackTrace->topSourceURL(), stackTrace->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0);
+ if (stackTrace && !stackTrace->isEmpty()) {
+ const V8StackTrace* stackTracePtr = stackTrace.get();
+ return SourceLocation::create(stackTracePtr->topSourceURL(), stackTracePtr->topLineNumber(), stackTracePtr->topColumnNumber(), std::move(stackTrace), 0);
+ }
return SourceLocation::create(url, lineNumber, columnNumber, std::move(stackTrace));
}
@@ -50,8 +52,10 @@ PassOwnPtr<SourceLocation> SourceLocation::capture(const String& url, unsigned l
PassOwnPtr<SourceLocation> SourceLocation::capture(ExecutionContext* executionContext)
{
std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace();
- if (stackTrace && !stackTrace->isEmpty())
- return SourceLocation::create(stackTrace->topSourceURL(), stackTrace->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0);
+ if (stackTrace && !stackTrace->isEmpty()) {
+ const V8StackTrace* stackTracePtr = stackTrace.get();
+ return SourceLocation::create(stackTracePtr->topSourceURL(), stackTracePtr->topLineNumber(), stackTracePtr->topColumnNumber(), std::move(stackTrace), 0);
+ }
Document* document = executionContext && executionContext->isDocument() ? toDocument(executionContext) : nullptr;
if (document) {