You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Detection of having reached the end of file was not done correctly. (#232)
* fix: Detection of having reached the end of file was not done correctly. All changes revolve around the fact that the last address of any input file is
baseAddress + fileSize - 1 when size > 0 and
baseAddress when size == 0
* Adjust past eof check to occur in the byte after the input file's last.
* Adjust past eof check to occur in the byte after the input file's last.
* Reverted unnecessary changes and rewrote for efficiency (no storage)
if (templatePattern->getSection() == ptrn::Pattern::MainSectionId)
202
-
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize() + 1))
202
+
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize()))
203
203
err::E0004.throwError("Array expanded past end of the data before a null-entry was found.", "Try using a while-sized array instead to limit the size of the array.", this->getLocation());
if (outputPattern->getSection() == ptrn::Pattern::MainSectionId)
249
-
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize() + 1))
249
+
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize()))
250
250
err::E0004.throwError("Array expanded past end of the data.", { }, this->getLocation());
251
251
}
252
252
@@ -327,7 +327,7 @@ namespace pl::core::ast {
327
327
size_t patternCount = patterns.size();
328
328
329
329
if (arrayPattern->getSection() == ptrn::Pattern::MainSectionId)
330
-
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize() + 1))
330
+
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize()))
331
331
err::E0004.throwError("Array expanded past end of the data.", fmt::format("Entry {} exceeded data by {} bytes.", i, evaluator->getReadOffset() - evaluator->getDataSize()), this->getLocation());
332
332
333
333
if (!patterns.empty())
@@ -360,7 +360,7 @@ namespace pl::core::ast {
360
360
size_t patternCount = patterns.size();
361
361
362
362
if (arrayPattern->getSection() == ptrn::Pattern::MainSectionId)
363
-
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize() + 1))
363
+
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize()))
364
364
err::E0004.throwError("Array expanded past end of the data before termination condition was met.", { }, this->getLocation());
365
365
366
366
if (!patterns.empty())
@@ -398,7 +398,7 @@ namespace pl::core::ast {
398
398
std::vector<u8> buffer(pattern->getSize());
399
399
400
400
if (arrayPattern->getSection() == ptrn::Pattern::MainSectionId)
401
-
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize() + 1))
401
+
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize()))
402
402
err::E0004.throwError("Array expanded past end of the data before a null-entry was found.", "Try using a while-sized array instead to limit the size of the array.", this->getLocation());
if (arrayPattern->getSection() == ptrn::Pattern::MainSectionId)
153
-
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize() + 1))
153
+
if ((evaluator->getReadOffset() - evaluator->getDataBaseAddress()) > (evaluator->getDataSize()))
154
154
err::E0004.throwError("Bitfield array expanded past end of the data.", fmt::format("Entry {} exceeded data by {} bytes.", dataIndex, evaluator->getReadOffset() - evaluator->getDataSize()), this->getLocation());
155
155
156
156
auto ctrlFlow = evaluator->getCurrentControlFlowStatement();
0 commit comments