Extend ValueLoader::LoadStringValue() to accept a max length
parameter. When a CStringValue is representing an array, use the array's length to limit how many bytes we read. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39795 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -188,10 +188,10 @@ ValueLoader::LoadValue(ValueLocation* location, type_code valueType,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ValueLoader::LoadStringValue(BVariant& location, BString& _value)
|
ValueLoader::LoadStringValue(BVariant& location, size_t maxSize, BString& _value)
|
||||||
{
|
{
|
||||||
static const size_t kMaxStringSize = 255;
|
static const size_t kMaxStringSize = 255;
|
||||||
|
|
||||||
return fTeamMemory->ReadMemoryString(location.ToUInt64(), kMaxStringSize,
|
return fTeamMemory->ReadMemoryString(location.ToUInt64(),
|
||||||
_value);
|
maxSize > kMaxStringSize ? kMaxStringSize : maxSize, _value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
BVariant& _value);
|
BVariant& _value);
|
||||||
|
|
||||||
status_t LoadStringValue(BVariant& location,
|
status_t LoadStringValue(BVariant& location,
|
||||||
BString& _value);
|
size_t maxSize, BString& _value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Architecture* fArchitecture;
|
Architecture* fArchitecture;
|
||||||
|
|||||||
@@ -69,16 +69,20 @@ CStringValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
|||||||
BVariant addressData;
|
BVariant addressData;
|
||||||
BString valueData;
|
BString valueData;
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
|
size_t maxSize = 255;
|
||||||
if (dynamic_cast<AddressType*>(fType) != NULL) {
|
if (dynamic_cast<AddressType*>(fType) != NULL) {
|
||||||
error = valueLoader->LoadValue(location, valueType, false,
|
error = valueLoader->LoadValue(location, valueType, false,
|
||||||
addressData);
|
addressData);
|
||||||
} else
|
} else {
|
||||||
addressData.SetTo(location->PieceAt(0).address);
|
addressData.SetTo(location->PieceAt(0).address);
|
||||||
|
maxSize = dynamic_cast<ArrayType*>(fType)
|
||||||
|
->DimensionAt(0)->CountElements();
|
||||||
|
}
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
error = valueLoader->LoadStringValue(addressData, valueData);
|
error = valueLoader->LoadStringValue(addressData, maxSize, valueData);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user