aboutsummaryrefslogtreecommitdiff
path: root/src/common/DataStores/DB2FileLoader.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-02-03 23:41:31 +0100
committerShauren <shauren.trinity@gmail.com>2023-02-03 23:41:31 +0100
commit01965086ef1896a8c01bd69d1a2ee5b7e5076c5c (patch)
tree5cfd6612d7f3146b26adad606b3a8b96e4ca8b56 /src/common/DataStores/DB2FileLoader.cpp
parent65adaf8c430c61c70eb46c2830ec29f7c9d483e1 (diff)
Core/DataStores: Fixed string fields containing empty strings in some 10.0.5 db2 files
Closes #28805
Diffstat (limited to 'src/common/DataStores/DB2FileLoader.cpp')
-rw-r--r--src/common/DataStores/DB2FileLoader.cpp10
1 files changed, 8 insertions, 2 deletions
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<char const*>(_stringTable)) // ensure string is inside _stringTable
+ reinterpret_cast<LocalizedString*>(&recordData[offset])->Str[locale] = stringPool + (string - reinterpret_cast<char const*>(_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<char const*>(_stringTable)) // ensure string is inside _stringTable
+ *reinterpret_cast<char**>(&recordData[offset]) = stringPool + (string - reinterpret_cast<char const*>(_stringTable));
+
offset += sizeof(char*);
break;
}