diff --git a/src/core/buffer.c b/src/core/buffer.c index 9b3fbe5a..1384101d 100644 --- a/src/core/buffer.c +++ b/src/core/buffer.c @@ -91,9 +91,7 @@ void janet_buffer_extra(JanetBuffer *buffer, int32_t n) { } int32_t new_size = buffer->count + n; if (new_size > buffer->capacity) { - size_t new_capacity_sizet = (size_t) (new_size) * 2; - if (new_capacity_sizet > INT32_MAX) new_capacity_sizet = INT32_MAX; - int32_t new_capacity = (int32_t) new_capacity_sizet; + int32_t new_capacity = (new_size > (INT32_MAX / 2)) ? INT32_MAX : (new_size * 2); uint8_t *new_data = realloc(buffer->data, new_capacity * sizeof(uint8_t)); janet_gcpressure(new_capacity - buffer->capacity); if (NULL == new_data) { diff --git a/src/core/ev.c b/src/core/ev.c index 25558983..7795b320 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -398,13 +398,13 @@ static void janet_stream_marshal(void *p, JanetMarshalContext *ctx) { duph = s->handle; } else { DuplicateHandle( - GetCurrentProcess(), - s->handle, - GetCurrentProcess(), - &duph, - 0, - FALSE, - DUPLICATE_SAME_ACCESS); + GetCurrentProcess(), + s->handle, + GetCurrentProcess(), + &duph, + 0, + FALSE, + DUPLICATE_SAME_ACCESS); } janet_marshal_int64(ctx, (int64_t)(duph)); #else