summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/target/target.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 8901cd11..ce2d0856 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -772,6 +772,9 @@ int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buff
{
int unaligned = 4 - (address % 4);
+ if (unaligned > size)
+ unaligned = size;
+
if ((retval = target->type->write_memory(target, address, 1, unaligned, buffer)) != ERROR_OK)
return retval;
@@ -833,6 +836,9 @@ int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffe
{
int unaligned = 4 - (address % 4);
+ if (unaligned > size)
+ unaligned = size;
+
if ((retval = target->type->read_memory(target, address, 1, unaligned, buffer)) != ERROR_OK)
return retval;