From a0edf915ad86e37e9ac8b8a6b31547f458c532a1 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Mon, 16 Oct 2023 17:53:50 -0700 Subject: [PATCH] Remove test prints and fix cursor checks in dictionary. --- Buffer.cc | 1 + CMakeLists.txt | 2 +- TLV.cc | 15 +++++++++------ Test.cc | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Buffer.cc b/Buffer.cc index e062351..908acfa 100644 --- a/Buffer.cc +++ b/Buffer.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cc6cb1..d9e756a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) project(scsl LANGUAGES CXX - VERSION 0.2.4 + VERSION 0.2.5 DESCRIPTION "Shimmering Clarity Standard Library") set(CMAKE_CXX_STANDARD 14) diff --git a/TLV.cc b/TLV.cc index 2fccf2a..1fbcfb5 100644 --- a/TLV.cc +++ b/TLV.cc @@ -116,8 +116,10 @@ FindTag(Arena &arena, uint8_t *cursor, Record &rec) { cursor = LocateTag(arena, cursor, rec); if (rec.Tag != TAG_EMPTY) { - std::cout << "skipping record\n"; cursor = SkipRecord(rec, cursor); + if (!arena.CursorInArena(cursor)) { + cursor = nullptr; + } } return cursor; @@ -134,23 +136,24 @@ LocateTag(Arena &arena, uint8_t *cursor, Record &rec) } if (cursor == nullptr) { - std::cout << "move cursor to arena start\n"; cursor = arena.Start(); } - while ((tag = cursor[0]) != rec.Tag) { + while (((tag = cursor[0]) != rec.Tag) && + (arena.CursorInArena(cursor))) { assert(arena.CursorInArena(cursor)); - std::cout << "cursor is in arena\n"; len = cursor[1]; - std::cout << "record length" << len << "\n"; if (!spaceAvailable(arena, cursor, len)) { - std::cout << "no space available\n"; return nullptr; } cursor += len; cursor += 2; } + if (!arena.CursorInArena(cursor)) { + return nullptr; + } + if (tag != rec.Tag) { return nullptr; } diff --git a/Test.cc b/Test.cc index 44042c5..2aad211 100644 --- a/Test.cc +++ b/Test.cc @@ -23,6 +23,7 @@ #include "Exceptions.h" #include "Test.h" +#include #include #include