Skip to content

Commit ec79d20

Browse files
committed
fix: resolved issue causing the same module to be loaded twice when loaded once with the full path and once with only the package path
1 parent ceec26a commit ec79d20

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

argon/vm/datatype/arobject.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ const TypeInfo TypeTrait = {
273273
nullptr,
274274
nullptr,
275275
nullptr,
276-
nullptr,
276+
type_compare,
277277
nullptr,
278278
nullptr,
279279
nullptr,

argon/vm/importer/import.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,30 @@ String *SanitizeModulePath(String *name, const String *path_sep) {
856856

857857
Release(altsep);
858858

859+
auto last_sep = StringRFind(res, path_sep);
860+
if (last_sep < 0)
861+
return res;
862+
863+
auto mname_length = ARGON_RAW_STRING_LENGTH(res) - (last_sep + 1);
864+
if (mname_length >= ARGON_RAW_STRING_LENGTH(res) - mname_length)
865+
return res;
866+
867+
auto ok = argon::vm::memory::MemoryCompare(
868+
(ARGON_RAW_STRING(name) + last_sep) - mname_length,
869+
(ARGON_RAW_STRING(name) + last_sep + 1),
870+
mname_length);
871+
872+
if (ok == 0) {
873+
if ((name = StringSubs(res, 0, last_sep)) == nullptr) {
874+
Release(res);
875+
return nullptr;
876+
}
877+
878+
Release(res);
879+
880+
return name;
881+
}
882+
859883
return res;
860884
}
861885

0 commit comments

Comments
 (0)