From 01965086ef1896a8c01bd69d1a2ee5b7e5076c5c Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 3 Feb 2023 23:41:31 +0100 Subject: Core/DataStores: Fixed string fields containing empty strings in some 10.0.5 db2 files Closes #28805 --- src/common/DataStores/DB2FileLoader.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/common/DataStores/DB2FileLoader.cpp') diff --git a/src/common/DataStores/DB2FileLoader.cpp b/src/common/DataStores/DB2FileLoader.cpp index f15864e4c7b..ab2c5a99f50 100644 --- a/src/common/DataStores/DB2FileLoader.cpp +++ b/src/common/DataStores/DB2FileLoader.cpp @@ -575,13 +575,19 @@ char* DB2FileLoaderRegularImpl::AutoProduceStrings(char** indexTable, uint32 ind break; case FT_STRING: { - ((LocalizedString*)(&recordData[offset]))->Str[locale] = stringPool + (RecordGetString(rawRecord, x, z) - (char const*)_stringTable); + char const* string = RecordGetString(rawRecord, x, z); + if (string >= reinterpret_cast(_stringTable)) // ensure string is inside _stringTable + reinterpret_cast(&recordData[offset])->Str[locale] = stringPool + (string - reinterpret_cast(_stringTable)); + offset += sizeof(LocalizedString); break; } case FT_STRING_NOT_LOCALIZED: { - *((char**)(&recordData[offset])) = stringPool + (RecordGetString(rawRecord, x, z) - (char const*)_stringTable); + char const* string = RecordGetString(rawRecord, x, z); + if (string >= reinterpret_cast(_stringTable)) // ensure string is inside _stringTable + *reinterpret_cast(&recordData[offset]) = stringPool + (string - reinterpret_cast(_stringTable)); + offset += sizeof(char*); break; } -- cgit v1.2.3