Fix 54be756: Terminating NUL byte was not skipped in ReadString(). (#12462)

This commit is contained in:
Peter Nelson 2024-04-09 15:15:09 +01:00 committed by GitHub
parent 883d3e7a9f
commit 2976a46d06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -274,7 +274,8 @@ public:
char *string = reinterpret_cast<char *>(data);
size_t string_length = ttd_strnlen(string, Remaining());
Skip(string_length);
/* Skip past the terminating NUL byte if it is present, but not more than remaining. */
Skip(std::min(string_length + 1, Remaining()));
return std::string_view(string, string_length);
}