diff -r 88f0f3d6cce6 -r d0be3ddbba1e core/systems/LibrarySys.cpp --- a/core/systems/LibrarySys.cpp Thu Apr 17 06:08:18 2008 +0000 +++ b/core/systems/LibrarySys.cpp Thu Apr 17 09:19:36 2008 +0000 @@ -352,21 +352,26 @@ const char *LibrarySystem::GetFileExtension(const char *filename) { - size_t end = strlen(filename) - 1; + size_t len, end, i; + + len = strlen(filename); - for (size_t i = end; i >= 0; i--) + /* Minimum string length for filename with ext would be 3; example: a.a */ + if (len < 3) { - if (i > end) + return NULL; + } + + end = len - 1; + + for (i = end; i <= end; i--) + { + if (filename[i] == '/') { break; } - if (filename[i] == PLATFORM_SEP_CHAR || filename[i] == PLATFORM_SEP_ALTCHAR) - { - break; - } - - if (filename[i] == '.' && i != end) + if (filename[i] == '.' && i != end && i != 0) { return &filename[++i]; }