\r
// is this a dir or a full path?\r
if (!plat_is_dir(curr_path)) {\r
- char *p = curr_path + strlen(curr_path) - 1;\r
- for (; p > curr_path && *p != '/'; p--)\r
- ;\r
- *p = 0;\r
- curr_path_restore = p;\r
- snprintf(sel_fname, sizeof(sel_fname), "%s", p + 1);\r
+ char *p = strrchr(curr_path, '/');\r
+ if (p != NULL) {\r
+ *p = 0;\r
+ curr_path_restore = p;\r
+ snprintf(sel_fname, sizeof(sel_fname), "%s", p + 1);\r
+ }\r
\r
if (rom_fname_reload[0] == 0)\r
show_help = 2;\r