Fid double free in virtual keyboard (#10999)
Found via portduino. As there are two separate references to this pointer, they both could call free
This commit is contained in:
co-authored by
GitHub
parent
5513c36757
commit
77292c8415
@@ -1038,10 +1038,9 @@ void NotificationRenderer::drawTextInput(OLEDDisplay *display, OLEDDisplayUiStat
|
|||||||
// Cancel virtual keyboard - call callback with empty string to indicate timeout
|
// Cancel virtual keyboard - call callback with empty string to indicate timeout
|
||||||
auto callback = textInputCallback; // Store callback before clearing
|
auto callback = textInputCallback; // Store callback before clearing
|
||||||
|
|
||||||
// Clean up first to prevent re-entry
|
// Clean up first to prevent re-entry. The keyboard belongs to OnScreenKeyboardModule; only stop()
|
||||||
delete virtualKeyboard;
|
// may free it, and it clears virtualKeyboard/textInputCallback for us.
|
||||||
virtualKeyboard = nullptr;
|
OnScreenKeyboardModule::instance().stop(false);
|
||||||
textInputCallback = nullptr;
|
|
||||||
resetBanner();
|
resetBanner();
|
||||||
|
|
||||||
// Call callback after cleanup
|
// Call callback after cleanup
|
||||||
@@ -1060,9 +1059,7 @@ void NotificationRenderer::drawTextInput(OLEDDisplay *display, OLEDDisplayUiStat
|
|||||||
bool handled = OnScreenKeyboardModule::processVirtualKeyboardInput(inEvent, virtualKeyboard);
|
bool handled = OnScreenKeyboardModule::processVirtualKeyboardInput(inEvent, virtualKeyboard);
|
||||||
if (!handled && inEvent.inputEvent == INPUT_BROKER_CANCEL) {
|
if (!handled && inEvent.inputEvent == INPUT_BROKER_CANCEL) {
|
||||||
auto callback = textInputCallback;
|
auto callback = textInputCallback;
|
||||||
delete virtualKeyboard;
|
OnScreenKeyboardModule::instance().stop(false); // sole owner of the keyboard; also clears our aliases
|
||||||
virtualKeyboard = nullptr;
|
|
||||||
textInputCallback = nullptr;
|
|
||||||
resetBanner();
|
resetBanner();
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback("");
|
callback("");
|
||||||
|
|||||||
Reference in New Issue
Block a user