summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2013-05-01 22:01:40 +0000
committerSean Callanan <scallanan@apple.com>2013-05-01 22:01:40 +0000
commit7f13bd7678b3e8d21720f720c8e98b2497ec8c94 (patch)
tree5c99a5f2404bdc9e902652ab1be4d1e50fb3ceb0 /lldb/source/Target/Process.cpp
parent160c9d81e07fec2d6299a9f31bb004f1b97419a6 (diff)
downloadbcm5719-llvm-7f13bd7678b3e8d21720f720c8e98b2497ec8c94.tar.gz
bcm5719-llvm-7f13bd7678b3e8d21720f720c8e98b2497ec8c94.zip
Fixed Process::ReadScalarIntegerFromMemory()
to report proper errors when the size is not correct. <rdar://problem/13784456> llvm-svn: 180888
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r--lldb/source/Target/Process.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index f60adca741e..95abb7945b3 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2653,10 +2653,22 @@ Process::ReadScalarIntegerFromMemory (addr_t addr,
{
DataExtractor data (&uval, sizeof(uval), GetByteOrder(), GetAddressByteSize());
lldb::offset_t offset = 0;
- if (byte_size <= 4)
- scalar = data.GetMaxU32 (&offset, byte_size);
+
+ if (byte_size == 0)
+ {
+ error.SetErrorString ("byte size is zero");
+ }
+ else if (byte_size & (byte_size - 1))
+ {
+ error.SetErrorStringWithFormat ("byte size %u is not a power of 2", byte_size);
+ }
else
- scalar = data.GetMaxU64 (&offset, byte_size);
+ {
+ if (byte_size <= 4)
+ scalar = data.GetMaxU32 (&offset, byte_size);
+ else
+ scalar = data.GetMaxU64 (&offset, byte_size);
+ }
if (is_signed)
scalar.SignExtend(byte_size * 8);
OpenPOWER on IntegriCloud