14697e2af2eca5b1be9c6c7fe334a55c02df19e9
operator< computed end2 as valuex.getData() + valuex.getLength() - mixing an absolute pointer (getData(), the buffer start) with a cursor-relative length (getLength(), remaining-from-cursor). For any ZString with a non-zero cursor offset this produces an end pointer short of the true buffer end by exactly the amount already consumed, truncating the comparison early. Fixed to use valuex.data + valuex.length (the true end), matching how end1 was already computed for *this. operator<=, >=, and > were separately broken (flagged by the codes own TODO comment) - they compared via strncmp from data (ignoring cursor entirely), inconsistent with operator< and with each other. Replaced all three with derivations from the now-correct operator< (a <= b is !(b < a), etc.) - guarantees trichotomy by construction instead of three independently-written comparison loops. substring(start, len): when the requested length overran the buffer, computed newlen as endChar - end (the overrun amount) instead of end - startChar (the actual remaining valid length) - backwards, and stored into a char (max 127), silently wrapping for longer strings. Fixed the formula and widened to size_t. trimCRLF(): read *(data + length - 1) unconditionally, including when length is already 0 - one byte before the buffer on an empty string. Guarded both checks on length > 0. Verified: full local compile (identical result to before - 13/20 clean, same pre-existing StreamReader.h-blocked failures, nothing new broken); a dedicated runtime test exercising all three fixes plus a trichotomy check across multiple cursor offsets - all 13 assertions pass. Test file not included in this commit.
Description
This repository contains the CoreUtils library. CoreUtils provides support for ServerCore, JetCore and other subsystem libraries used in higher functions.
33 MiB
0 Stars
1 Watchers
0 Forks
Languages
C++
97.8%
Makefile
1.9%
Shell
0.3%