Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: printing crash when settings invalid #38165

Merged
merged 1 commit into from
May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions patches/chromium/printing.patch
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@
// Tells the RenderFrame to switch the CSS to print media type, render every
// requested page, and then switch back the CSS to display media type.
- PrintRequestedPages();
+ PrintRequestedPages(bool silent, mojo_base.mojom.DictionaryValue settings);

Check failure on line 603 in patches/chromium/printing.patch

View check run for this annotation

trop / Backportable? - 24-x-y

patches/chromium/printing.patch#L603

Patch Conflict
Raw output
++<<<<<<< HEAD
 +index e82872cdb7836caf3da45c8a8af29daafcaee3c3..16c652bba239e733fb107a9e1e100f6fdd9010c9 100644
++=======
+ index f1e72946e69e8e12d0436366587648b683d9f4f8..205598b3b14d72dc97bf664143a97073677fe52b 100644
++>>>>>>> fix: printing crash when settings invalid

Check failure on line 603 in patches/chromium/printing.patch

View check run for this annotation

trop / Backportable? - 24-x-y

patches/chromium/printing.patch#L603

Patch Conflict
Raw output
++<<<<<<< HEAD
 +index e82872cdb7836caf3da45c8a8af29daafcaee3c3..16c652bba239e733fb107a9e1e100f6fdd9010c9 100644
++=======
+ index f1e72946e69e8e12d0436366587648b683d9f4f8..205598b3b14d72dc97bf664143a97073677fe52b 100644
++>>>>>>> fix: printing crash when settings invalid

// Requests the frame to be printed with specified parameters. This is used
// to programmatically produce PDF by request from the browser (e.g. over
Expand All @@ -617,7 +617,7 @@
// Tells the browser printing failed.
PrintingFailed(int32 cookie, PrintFailureReason reason);
diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc
index f1e72946e69e8e12d0436366587648b683d9f4f8..2c7db9c160ac200a2abf671c9b01a24acba4207a 100644
index f1e72946e69e8e12d0436366587648b683d9f4f8..205598b3b14d72dc97bf664143a97073677fe52b 100644
--- a/components/printing/renderer/print_render_frame_helper.cc
+++ b/components/printing/renderer/print_render_frame_helper.cc
@@ -45,6 +45,7 @@
Expand Down Expand Up @@ -737,18 +737,18 @@
- GetPrintManagerHost()->GetDefaultPrintSettings(&settings.params);
+ mojom::PrintPagesParamsPtr settings;
+ if (new_settings.empty()) {
+ settings = mojom::PrintPagesParams::New();
+ settings->params = mojom::PrintParams::New();
+ GetPrintManagerHost()->GetDefaultPrintSettings(&settings->params);
+ } else {
+ GetPrintManagerHost()->UpdatePrintSettings(
+ std::move(new_settings), &settings);
+ }

// Check if the printer returned any settings, if the settings are null,
// assume there are no printer drivers configured. So safely terminate.

Check failure on line 749 in patches/chromium/printing.patch

View check run for this annotation

trop / Backportable? - 24-x-y

patches/chromium/printing.patch#L740-L749

Patch Conflict
Raw output
++<<<<<<< HEAD
 +   // Check if the printer returned any settings, if the settings is empty, we
 +   // can safely assume there are no printer drivers configured. So we safely
 +   // terminate.
 +-  const bool result = PrintMsgPrintParamsIsValid(*settings.params);
 ++  const bool result = PrintMsgPrintParamsIsValid(*settings->params);
 + 
 +   // Reset to default values.
 +   ignore_css_margins_ = false;
 +-  settings.pages.clear();
 ++  settings->pages.clear();
++=======
+    // Check if the printer returned any settings, if the settings are null,
+    // assume there are no printer drivers configured. So safely terminate.
+ -  if (!settings.params) {
+ +  if (!settings || !settings->params) {
+      // Caller will reset `print_pages_params_`.
+      return false;
+    }
++>>>>>>> fix: printing crash when settings invalid

Check failure on line 749 in patches/chromium/printing.patch

View check run for this annotation

trop / Backportable? - 24-x-y

patches/chromium/printing.patch#L740-L749

Patch Conflict
Raw output
++<<<<<<< HEAD
 +   // Check if the printer returned any settings, if the settings is empty, we
 +   // can safely assume there are no printer drivers configured. So we safely
 +   // terminate.
 +-  const bool result = PrintMsgPrintParamsIsValid(*settings.params);
 ++  const bool result = PrintMsgPrintParamsIsValid(*settings->params);
 + 
 +   // Reset to default values.
 +   ignore_css_margins_ = false;
 +-  settings.pages.clear();
 ++  settings->pages.clear();
++=======
+    // Check if the printer returned any settings, if the settings are null,
+    // assume there are no printer drivers configured. So safely terminate.
+ -  if (!settings.params) {
+ +  if (!settings || !settings->params) {
+      // Caller will reset `print_pages_params_`.
+      return false;
+    }
++>>>>>>> fix: printing crash when settings invalid
- if (!settings.params) {
+ if (!settings->params) {
+ if (!settings || !settings->params) {
// Caller will reset `print_pages_params_`.
return false;
}
Expand Down