From 87efa251d5ff7474bc5827d6aa1957a12880e3a4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 21 Nov 2009 17:48:05 +0100 Subject: [PATCH] Fix a bug in icondir handling --- gfxmenu/icon_manager.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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);