Bug 1930836 - Initialize returned values in GetSelection{Start,End}IgnoringType. a=dmeehan

Returning uninitialized values is undefined behavior, and while the API
is such that the caller code wouldn't use the value in the case it's not
initialized, the C++ standard doesn't allow it and now clang 19 has a
change in an optimization pass that can end up miscompiling the code as
result.

Original Revision: https://phabricator.services.mozilla.com/D228769

Differential Revision: https://phabricator.services.mozilla.com/D229692
This commit is contained in:
Mike Hommey 2024-11-27 17:59:46 +00:00
parent bf64ef1085
commit 10865df751

View file

@ -5717,7 +5717,7 @@ Nullable<uint32_t> HTMLInputElement::GetSelectionStart(ErrorResult& aRv) {
}
uint32_t HTMLInputElement::GetSelectionStartIgnoringType(ErrorResult& aRv) {
uint32_t selEnd, selStart;
uint32_t selEnd = 0, selStart = 0;
GetSelectionRange(&selStart, &selEnd, aRv);
return selStart;
}
@ -5748,7 +5748,7 @@ Nullable<uint32_t> HTMLInputElement::GetSelectionEnd(ErrorResult& aRv) {
}
uint32_t HTMLInputElement::GetSelectionEndIgnoringType(ErrorResult& aRv) {
uint32_t selEnd, selStart;
uint32_t selEnd = 0, selStart = 0;
GetSelectionRange(&selStart, &selEnd, aRv);
return selEnd;
}