Skip to content

Commit cec3fbb

Browse files
fix: Free home-screen plugin tagline before reallocating
get_appname_and_tagline() allocates g_tag_line on every home-screen transition where the caller is a plugin, but nothing freed the prior buffer first ? the comment at the allocation point even acknowledged "will never be deallocated". Each return to the home screen during a plugin-driven session (post-tx, post-cancel, multi-flow plugins) therefore leaked roughly the plugin name length plus the tagline template into the shared app-memory pool, slowly starving the rest of the session. Release the previous allocation with APP_MEM_FREE_AND_NULL() before the next APP_MEM_CALLOC() so the pool only ever holds one live tagline buffer. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent a94a731 commit cec3fbb

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/nbgl/ui_home.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,13 @@ static void get_appname_and_tagline(const char **appname, const char **tagline)
237237
return;
238238
}
239239
size_t line_len = 1 + strlen(FORMAT_PLUGIN) + name_len;
240-
// Allocate the buffer - will never be deallocated...
240+
// Free any tagline left over from a previous home transition
241+
// before allocating a new one; without this, repeated returns
242+
// to the home screen in the same session accumulate orphaned
243+
// buffers in the app-memory pool.
244+
if (g_tag_line != NULL) {
245+
APP_MEM_FREE_AND_NULL((void **) &g_tag_line);
246+
}
241247
if (APP_MEM_CALLOC((void **) &g_tag_line, line_len) == true) {
242248
snprintf(g_tag_line, line_len, FORMAT_PLUGIN, *appname);
243249
*tagline = g_tag_line;

0 commit comments

Comments
 (0)