diff --git a/gfxmenu/icon_manager.c b/gfxmenu/icon_manager.c index b7b891991..0c304ede0 100644 --- a/gfxmenu/icon_manager.c +++ b/gfxmenu/icon_manager.c @@ -137,14 +137,21 @@ static struct grub_video_bitmap * try_loading_icon (grub_gfxmenu_icon_manager_t mgr, const char *dir, const char *class_name) { - char *path = grub_malloc (grub_strlen (dir) - + grub_strlen (class_name) - + grub_strlen (icon_extension) - + 1); + char *path; + int l; + + path = grub_malloc (grub_strlen (dir) + grub_strlen (class_name) + + grub_strlen (icon_extension) + 3); if (! path) return 0; grub_strcpy (path, dir); + l = grub_strlen (path); + if (path[l-1] != '/') + { + path[l] = '/'; + path[l+1] = 0; + } grub_strcat (path, class_name); grub_strcat (path, icon_extension);