From bcb394d6b1ce176843b5993f6ba1f8ae8520006e Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Mon, 8 Nov 2010 02:40:15 +0000 Subject: [PATCH] Bugfix: ReadMemoryString() never actually copied the data into the passed in string. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39354 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debugger/model/TeamMemory.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/apps/debugger/model/TeamMemory.cpp b/src/apps/debugger/model/TeamMemory.cpp index fca7143898..1afe8a9a93 100644 --- a/src/apps/debugger/model/TeamMemory.cpp +++ b/src/apps/debugger/model/TeamMemory.cpp @@ -23,23 +23,21 @@ TeamMemory::ReadMemoryString(target_addr_t address, size_t maxLength, { char buffer[B_PAGE_SIZE]; - BString string; - + _string.Truncate(0); while (maxLength > 0) { // read at max maxLength bytes, but don't read across page bounds size_t toRead = std::min(maxLength, B_PAGE_SIZE - size_t(address % B_PAGE_SIZE)); - ssize_t bytesRead = ReadMemory(address, buffer, toRead); if (bytesRead < 0) - return string.Length() == 0 ? bytesRead : B_OK; + return _string.Length() == 0 ? bytesRead : B_OK; if (bytesRead == 0) - return string.Length() == 0 ? B_BAD_ADDRESS : B_OK; + return _string.Length() == 0 ? B_BAD_ADDRESS : B_OK; // append the bytes read size_t length = strnlen(buffer, bytesRead); - string.Append(buffer, length); + _string.Append(buffer, length); // stop at end of string if (length < (size_t)bytesRead)