[BugFix] keyremap browse missing root, entry count off by 1

browse_context was missing its root causing a NULL deref

Export User Keys was looking for at least 4 entries when it only needed 3

Change-Id: If92ecccb36bd54e1b850ac2a969fe262b5d7fd14
This commit is contained in:
William Wilgus 2022-12-31 07:01:04 -05:00 committed by William Wilgus
parent 1773e56447
commit 855540e1f5

View file

@ -521,9 +521,11 @@ static int keyremap_export_current(char *filenamebuf, size_t bufsz)
int entry_count = ctx_data.ctx_count + ctx_data.act_count + 1;;/* (ctx_count + ctx_count + act_count + 1) */ int entry_count = ctx_data.ctx_count + ctx_data.act_count + 1;;/* (ctx_count + ctx_count + act_count + 1) */
if (entry_count <= 3) if (entry_count < 3)
{
logf("%s: Not enough entries", __func__);
return 0; return 0;
}
int fd = rb->open(filenamebuf, O_WRONLY | O_CREAT | O_TRUNC, 0666); int fd = rb->open(filenamebuf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0) if (fd < 0)
@ -620,6 +622,7 @@ static void keyremap_import_user_keys(void)
.icon = Icon_Plugin, .icon = Icon_Plugin,
.buf = buf, .buf = buf,
.bufsize = sizeof(buf), .bufsize = sizeof(buf),
.root = "/",
}; };
if (rb->rockbox_browse(&browse) == GO_TO_PREVIOUS) if (rb->rockbox_browse(&browse) == GO_TO_PREVIOUS)