igzip: Fix bug in create_rand_repeat_data

Change-Id: Ib3ab731ea9a96cdbd0380d6a88b3837ae0de0815
Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
Roy Oursler 2018-05-01 18:33:09 -07:00 committed by Greg Tucker
parent 054758ea63
commit a778455448

View File

@ -182,8 +182,10 @@ void create_rand_repeat_data(uint8_t * data, int size)
max_repeat_data += power_of_2_array[power];
if (size-- > 0)
if (size > 0) {
size--;
*data++ = rand();
}
while (size > 0) {
next_data = rand() % max_repeat_data;
@ -208,8 +210,10 @@ void create_rand_repeat_data(uint8_t * data, int size)
*data = *(data - distance);
data++;
}
} else
} else {
memcpy(data, data - distance, length);
data += length;
}
}
}
}