From a787d21b3f7d35cee3331d652f9ce70ec800f88d Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Tue, 22 Apr 2025 15:46:31 +0300 Subject: [PATCH] fix(core): preallocate `save_screen_directory` to allow heap checking Otherwise, free heap memory will decrease after handling `DebugLinkRecordScreen`. [no changelog] --- core/src/apps/debug/__init__.py | 4 ++-- core/src/storage/debug.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/apps/debug/__init__.py b/core/src/apps/debug/__init__.py index 3c25bd0866..e9ebf47249 100644 --- a/core/src/apps/debug/__init__.py +++ b/core/src/apps/debug/__init__.py @@ -47,7 +47,7 @@ if __debug__: # Starting with "refresh00", allowing for 100 emulator restarts # without losing the order of the screenshots based on filename. display.save( - storage.save_screen_directory + f"/refresh{REFRESH_INDEX:0>2}-" + f"{storage.save_screen_directory.decode()}/refresh{REFRESH_INDEX:0>2}-" ) return True return False @@ -298,7 +298,7 @@ if __debug__: # so that the screenshots are not overwritten. global REFRESH_INDEX REFRESH_INDEX = msg.refresh_index - storage.save_screen_directory = msg.target_directory + storage.save_screen_directory[:] = msg.target_directory.encode() storage.save_screen = True # force repaint current layout, in order to take an initial screenshot diff --git a/core/src/storage/debug.py b/core/src/storage/debug.py index 3a2f9b71aa..cc225236e0 100644 --- a/core/src/storage/debug.py +++ b/core/src/storage/debug.py @@ -1,11 +1,13 @@ -from trezorutils import halt +from trezorutils import EMULATOR, halt if not __debug__: halt("Debugging is disabled") if __debug__: save_screen = False - save_screen_directory = "." + if EMULATOR: + save_screen_directory = bytearray(4096) + save_screen_directory[:] = b"." layout_watcher = False