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

Unified Diff: components/printing/renderer/print_web_view_helper.cc

Issue 2545853002: One more check for PrintWebViewHelper validity. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/printing/renderer/print_web_view_helper.cc
diff --git a/components/printing/renderer/print_web_view_helper.cc b/components/printing/renderer/print_web_view_helper.cc
index f44b36b49bf3e867c1f39c448529535a4b2bcebb..c72217ae3ca78cde181cc2a18029a1930ad7cd94 100644
--- a/components/printing/renderer/print_web_view_helper.cc
+++ b/components/printing/renderer/print_web_view_helper.cc
@@ -984,6 +984,8 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
// choose to ignore message or safely crash process.
++ipc_nesting_level_;
+ auto self = weak_ptr_factory_.GetWeakPtr();
+
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
@@ -1002,7 +1004,9 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
- --ipc_nesting_level_;
+ // Check if |this| is still valid. e.g. when OnPrintPages() returns.
+ if (self)
+ --ipc_nesting_level_;
return handled;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698