diff options
-rw-r--r-- | win32/isaac.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/win32/isaac.c b/win32/isaac.c index ba51d199a..2b02eaff2 100644 --- a/win32/isaac.c +++ b/win32/isaac.c | |||
@@ -214,20 +214,12 @@ ssize_t get_random_bytes(void *buf, ssize_t count) | |||
214 | ptr = (unsigned char *)t->randrsl; | 214 | ptr = (unsigned char *)t->randrsl; |
215 | while (count > 0) { | 215 | while (count > 0) { |
216 | int bytes_left = RAND_BYTES - rand_index; | 216 | int bytes_left = RAND_BYTES - rand_index; |
217 | ssize_t delta = MIN(bytes_left, count); | ||
217 | 218 | ||
218 | if (bytes_left >= count) { | 219 | memcpy(buf, ptr+rand_index, delta); |
219 | /* we have enough random bytes */ | 220 | buf += delta; |
220 | memcpy(buf, ptr+rand_index, count); | 221 | count -= delta; |
221 | rand_index += count; | 222 | rand_index += delta; |
222 | count = 0; | ||
223 | } | ||
224 | else { | ||
225 | /* insufficient bytes, use what we have */ | ||
226 | memcpy(buf, ptr+rand_index, bytes_left); | ||
227 | buf += bytes_left; | ||
228 | count -= bytes_left; | ||
229 | rand_index += bytes_left; | ||
230 | } | ||
231 | 223 | ||
232 | if (rand_index >= RAND_BYTES) { | 224 | if (rand_index >= RAND_BYTES) { |
233 | /* generate more */ | 225 | /* generate more */ |