1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-06 20:52:40 +00:00

fix(core): explicitly delete keyboard layout

- seems that keyboard LayoutObj was not properly deallocated resulting
in MemoryError. Fix by calling the dunder `del` method explicitly fixes
the issue
- the problem was on Model T (Bolt), but applying it for all layouts to
prevent similar problem
This commit is contained in:
obrusvit 2025-01-27 15:33:38 +01:00 committed by Vít Obrusník
parent 71306d0904
commit 15967a312b
4 changed files with 27 additions and 18 deletions

View File

@ -0,0 +1 @@
[T2T1] Fixed a bug resulting in restarting the recovery flow when inputting 33-word mnemonic.

View File

@ -32,21 +32,24 @@ async def request_word(
) -> str: ) -> str:
prompt = TR.recovery__type_word_x_of_y_template.format(word_index + 1, word_count) prompt = TR.recovery__type_word_x_of_y_template.format(word_index + 1, word_count)
can_go_back = word_index > 0 can_go_back = word_index > 0
if is_slip39: if is_slip39:
keyboard = trezorui_api.request_slip39( keyboard = trezorui_api.request_slip39(
prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back
) )
else: else:
keyboard = trezorui_api.request_bip39( keyboard = trezorui_api.request_bip39(
prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back
) )
word: str = await interact( try:
keyboard, word: str = await interact(
"mnemonic" if send_button_request else None, keyboard,
ButtonRequestType.MnemonicInput, "mnemonic" if send_button_request else None,
) ButtonRequestType.MnemonicInput,
)
finally:
keyboard.__del__()
return word return word

View File

@ -31,24 +31,25 @@ async def request_word(
prefill_word: str = "", prefill_word: str = "",
) -> str: ) -> str:
prompt = TR.recovery__word_x_of_y_template.format(word_index + 1, word_count) prompt = TR.recovery__word_x_of_y_template.format(word_index + 1, word_count)
can_go_back = word_index > 0 can_go_back = word_index > 0
if is_slip39: if is_slip39:
keyboard = trezorui_api.request_slip39( keyboard = trezorui_api.request_slip39(
prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back
) )
else: else:
keyboard = trezorui_api.request_bip39( keyboard = trezorui_api.request_bip39(
prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back
) )
word: str = await interact( try:
keyboard, word: str = await interact(
"mnemonic" if send_button_request else None, keyboard,
ButtonRequestType.MnemonicInput, "mnemonic" if send_button_request else None,
) ButtonRequestType.MnemonicInput,
)
finally:
keyboard.__del__()
return word return word

View File

@ -33,6 +33,7 @@ async def request_word(
) -> str: ) -> str:
prompt = TR.recovery__word_x_of_y_template.format(word_index + 1, word_count) prompt = TR.recovery__word_x_of_y_template.format(word_index + 1, word_count)
can_go_back = word_index > 0 can_go_back = word_index > 0
if is_slip39: if is_slip39:
keyboard = trezorui_api.request_slip39( keyboard = trezorui_api.request_slip39(
prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back
@ -42,11 +43,14 @@ async def request_word(
prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back prompt=prompt, prefill_word=prefill_word, can_go_back=can_go_back
) )
word: str = await interact( try:
keyboard, word: str = await interact(
"mnemonic" if send_button_request else None, keyboard,
ButtonRequestType.MnemonicInput, "mnemonic" if send_button_request else None,
) ButtonRequestType.MnemonicInput,
)
finally:
keyboard.__del__()
return word return word