aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2016-12-24 10:14:53 -0800
committerGitHub <noreply@github.com>2016-12-24 10:14:53 -0800
commit193f63094891cd3fe6a5032fef2c71d09f063ff4 (patch)
treed380c6bcfc3c8e835ed8321f6c1249014863999e
parentb474c22b33be7fa4969c0dfa9ccf172ce1bab5d0 (diff)
parentddb4caf84659462a487755e4cf484c1dc0bb8e16 (diff)
downloadriscv-openocd-193f63094891cd3fe6a5032fef2c71d09f063ff4.zip
riscv-openocd-193f63094891cd3fe6a5032fef2c71d09f063ff4.tar.gz
riscv-openocd-193f63094891cd3fe6a5032fef2c71d09f063ff4.tar.bz2
Merge pull request #11 from sifive/malloc_off_by_1
Correct off by 1 in malloc
-rw-r--r--src/flash/nor/fespi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/flash/nor/fespi.c b/src/flash/nor/fespi.c
index 27580d6..49583e9 100644
--- a/src/flash/nor/fespi.c
+++ b/src/flash/nor/fespi.c
@@ -676,7 +676,7 @@ void as_add_tx(struct algorithm_steps *as, unsigned count, const uint8_t *data)
while (count > 0) {
unsigned step_count = MIN(count, 255);
assert(as->used < as->size);
- as->steps[as->used] = malloc(step_count + 1);
+ as->steps[as->used] = malloc(step_count + 2);
as->steps[as->used][0] = STEP_TX;
as->steps[as->used][1] = step_count;
memcpy(as->steps[as->used] + 2, data, step_count);