Skip to content

fix: avoid crash in window.print() when prefilling native print dialog#50853

Open
trop[bot] wants to merge 1 commit into42-x-yfrom
trop/42-x-y-bp-fix-avoid-crash-in-window-print-when-prefilling-native-print-dialog-1775754884162
Open

fix: avoid crash in window.print() when prefilling native print dialog#50853
trop[bot] wants to merge 1 commit into42-x-yfrom
trop/42-x-y-bp-fix-avoid-crash-in-window-print-when-prefilling-native-print-dialog-1775754884162

Conversation

@trop
Copy link
Copy Markdown
Contributor

@trop trop bot commented Apr 9, 2026

Backport of #50843

See that PR for details.

Notes: Fixed a potential crash when using webContents.print().

When UpdatePrinterSettings() fails (e.g. the printer rejects the
requested resolution), OnError() nullifies print_info_ via
ReleaseContext(). The return value was not checked, so
AskUserForSettings() passed nil to [NSPrintPanel runModalWithPrintInfo:],
crashing in PJCSessionHasApplicationSetPrinter with a null PMPrintSession.

Check the return value and fall back to UseDefaultSettings() on failure
so the dialog opens with defaults instead of crashing.

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
@trop trop bot requested a review from a team as a code owner April 9, 2026 17:14
@trop trop bot requested review from a team and codebytere April 9, 2026 17:14
@trop trop bot added 42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants