Skip to content

Commit

Permalink
Fixed|libcore|ScriptSystem: Possible crash when importing modules
Browse files Browse the repository at this point in the history
The sorting predicate was not correct (not a bool), which could
confuse MSVC's std::list.
  • Loading branch information
skyjake committed Feb 22, 2015
1 parent f68216b commit 1a7177f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions doomsday/sdk/libcore/src/scriptsys/scriptsystem.cpp
Expand Up @@ -282,9 +282,11 @@ StringList ScriptSystem::nativeModules() const
return d->nativeModules.keys();
}

static int sortFilesByModifiedAt(File const *a, File const *b)
{
return de::cmp(a->status().modifiedAt, b->status().modifiedAt);
namespace internal {
static bool sortFilesByModifiedAt(File *a, File *b) {
DENG2_ASSERT(a != b);
return de::cmp(a->status().modifiedAt, b->status().modifiedAt) < 0;
}
}

File const *ScriptSystem::tryFindModuleSource(String const &name, String const &localPath)
Expand Down Expand Up @@ -337,7 +339,7 @@ File const *ScriptSystem::tryFindModuleSource(String const &name, String const &
{
continue;
}
matching.sort(sortFilesByModifiedAt);
matching.sort(internal::sortFilesByModifiedAt);
found = matching.back();
LOG_SCR_VERBOSE("Chose ") << found->path() << " out of " << dint(matching.size())
<< " candidates (latest modified)";
Expand Down

0 comments on commit 1a7177f

Please sign in to comment.