@@ -51,10 +51,6 @@ namespace newasm::Drivers::FileSystem_V
5151 }
5252 FORCE_INLINE inline void SaveFileTable (DISK& disk, const FILE_TABLE& table)
5353 {
54- auto t = table;
55- std::sort (t.begin (), t.end (), [](const auto & a, const auto & b) -> bool {
56- return a.pos < b.pos ;
57- });
5854 std::string buf (sizeof (FILE) * NewASM::Drivers::FileSystem_V::GetMaxFiles (), ' \0 ' );
5955 std::memcpy (&buf[0 ], t.data (), buf.size ());
6056 disk.WRITE_DSK (0 , buf);
@@ -97,13 +93,13 @@ namespace newasm::Drivers::FileSystem_V
9793 {
9894 std::vector<std::pair<DISK_POS, DISK_POS>> pairs;
9995 auto table = GetFileTable (disk);
100- std::sort (table.begin (), table.end (), [](const auto & a, const auto & b) -> bool {
101- return a.pos < b.pos ;
102- });
10396 for (int i = 0 ; i < table.size (); ++i)
10497 {
10598 pairs.push_back ({table[i].pos , table[i].pos + table[i].size });
10699 }
100+ std::sort (pairs.begin (), pairs.end (), [](const auto & a, const auto & b) -> bool {
101+ return a.first < b.first ;
102+ });
107103 if (pairs.size () == 1 )
108104 {
109105 return pairs.front ().second + 1 ;
@@ -152,6 +148,10 @@ namespace newasm::Drivers::FileSystem_V
152148 inline void MKFILE (DISK& disk, FILE_NAME name, const std::string& content)
153149 {
154150 using namespace NewASM ::Drivers::FileSystem_V;
151+ if (name.size () >= __newasm_MAX_FILENAME_LEN)
152+ {
153+ return ;
154+ }
155155 FILE_TABLE table = GetFileTable (disk);
156156 for (int i = 0 ; i < table.size (); ++i)
157157 {
0 commit comments