diff --git a/MString.cpp b/MString.cpp index 74ced36..301b54c 100644 --- a/MString.cpp +++ b/MString.cpp @@ -27,6 +27,24 @@ namespace coreutils { memcpy(this->data, data, length); cursor = this->data; } + + // Declared alongside MString(const char *data) but never implemented - + // invisible until a real executable actually needed this symbol + // resolved (a static library archive never checks for unresolved + // references, only the final link of a real binary does). Stores the + // raw pointer VALUE itself (not a dereference of it) as the string's + // bytes, matching how void* aliases are compared everywhere else in + // this codebase - by pointer identity, not by string content (e.g. + // TCPServer::getSessionByAlias() and TCPSession::compareAlias() both + // compare void* aliases directly) - so two MStrings built from the + // same alias value compare equal, and one built from an arbitrary + // (possibly non-string, possibly not even null-terminated) alias + // pointer never risks reading past it. + MString::MString(void *alias) { + setSize(sizeof(void *)); + memcpy(this->data, &alias, sizeof(void *)); + cursor = this->data; + } MString::MString(char *data, size_t length) { setSize(length);