Merge pull request #11 from sifive/malloc_off_by_1

Correct off by 1 in malloc
__archive__
Tim Newsome 2016-12-24 10:14:53 -08:00 committed by GitHub
commit 193f630948
1 changed files with 1 additions and 1 deletions

View File

@ -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);