From 7b756263c0188806fbc25af065a3ed362d6cd4f9 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 26 Feb 2023 10:56:11 +0200 Subject: [PATCH] Create a null element and return it --- Network/NetworkController.cpp | 9 ++++++++- include/vector.hpp | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Network/NetworkController.cpp b/Network/NetworkController.cpp index fce0329..a0ee353 100644 --- a/Network/NetworkController.cpp +++ b/Network/NetworkController.cpp @@ -113,7 +113,14 @@ namespace NetworkInterfaceManager DbgWriteScreen("DNS: %s", dhcp->DomainNameSystem.v4.ToStringLittleEndian()); TaskManager->Sleep(200); - /* TODO: This is a quick workaround we need DNS resolver asap. IP is time-a-g.nist.gov; https://tf.nist.gov/tf-cgi/servers.cgi */ + /* TODO: This is a quick workaround we need DNS resolver asap. + + https://tf.nist.gov/tf-cgi/servers.cgi + https://www.ntppool.org + + - 0.ro.pool.ntp.org ( {86, 127, 71, 168} ) + - time-a-g.nist.gov ( {129, 6, 15, 28} ) + */ InternetProtocol ip = {.v4 = {.Address = {129, 6, 15, 28}}, .v6 = {.Address = {}}}; NetworkUDP::Socket *NTP_Socket = udp->Connect(ip, 123); diff --git a/include/vector.hpp b/include/vector.hpp index 93d156b..250bc4c 100644 --- a/include/vector.hpp +++ b/include/vector.hpp @@ -149,7 +149,16 @@ public: VectorSize = Size; } - __no_instrument_function T &operator[](size_t Index) { return VectorBuffer[Index]; } + __no_instrument_function T &operator[](size_t Index) + { + if (!reinterpret_cast(&VectorBuffer[Index])) + { + warn("operator[]( %lld ) is null (requested by %#lx)", Index, __builtin_return_address(0)); + static T null_elem; + return null_elem; + } + return VectorBuffer[Index]; + } __no_instrument_function Vector &operator=(const Vector &Vector) {