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
|
||||
auto callback = textInputCallback; // Store callback before clearing
|
||||
|
||||
// Clean up first to prevent re-entry
|
||||
delete virtualKeyboard;
|
||||
virtualKeyboard = nullptr;
|
||||
textInputCallback = nullptr;
|
||||
// Clean up first to prevent re-entry. The keyboard belongs to OnScreenKeyboardModule; only stop()
|
||||
// may free it, and it clears virtualKeyboard/textInputCallback for us.
|
||||
OnScreenKeyboardModule::instance().stop(false);
|
||||
resetBanner();
|
||||
|
||||
// Call callback after cleanup
|
||||
@@ -1060,9 +1059,7 @@ void NotificationRenderer::drawTextInput(OLEDDisplay *display, OLEDDisplayUiStat
|
||||
bool handled = OnScreenKeyboardModule::processVirtualKeyboardInput(inEvent, virtualKeyboard);
|
||||
if (!handled && inEvent.inputEvent == INPUT_BROKER_CANCEL) {
|
||||
auto callback = textInputCallback;
|
||||
delete virtualKeyboard;
|
||||
virtualKeyboard = nullptr;
|
||||
textInputCallback = nullptr;
|
||||
OnScreenKeyboardModule::instance().stop(false); // sole owner of the keyboard; also clears our aliases
|
||||
resetBanner();
|
||||
if (callback) {
|
||||
callback("");
|
||||
|
||||
Reference in New Issue
Block a user