diff --git a/src/filesel.c b/src/filesel.c index b2424a57..99db5494 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -318,7 +318,7 @@ static void Read_dir_callback(void * pdata, const char *file_name, const word *u { int i; pos_last_dot++; - for (i = 0; i < (int)sizeof(long_ext) - 1; i++) + for (i = 0; i < (int)sizeof(long_ext) - 1 && unicode_name[pos_last_dot + i] != 0; i++) long_ext[i] = (unicode_name[pos_last_dot + i] < 256) ? unicode_name[pos_last_dot + i] : '?'; long_ext[i] = '\0'; file_name_ext = long_ext;