#49947: fix: potential std::stoi crash in Windows Toasts
Merged
Description of Change
Refs #48132
Fixes a bug that could occur if action_index_str contains a non-numeric value. In this case std::stoi throws std::invalid_argument or std::out_of_range, which without exception support crashes the process:
Received fatal exception 0xe06d7363
KERNELBASE!LoadLibraryExW [0x7ffe63023c28+1ea398]
Electron exited with code 3221226505.
Can be reproduced with:
const { Notification, app } = require('electron')
app.whenReady().then(() => {
const n = new Notification({
toastXml: `
<toast launch="type=action&action=NOTANUMBER&tag=12345">
<visual>
<binding template="ToastGeneric">
<text>Crash Test</text>
<text>Click me to trigger std::stoi crash</text>
</binding>
</visual>
<actions>
<action content="Bad Button" arguments="type=action&action=NOTANUMBER&tag=12345" activationType="foreground"/>
</actions>
</toast>`
})
n.show()
})Checklist
- PR description included
-
npm testpasses - PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: Fixed an issue where malformed custom toastXml could cause a Notification crash.
Backports
Semver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron