Skip to content

Commit 965008f

Browse files
committed
Fix integer overflow issue
1 parent f063136 commit 965008f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

test/test_base_alloc_linear.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ static void *start_routine(void *arg) {
2929
long TID = syscall(SYS_gettid);
3030

3131
for (int i = 0; i < ITERATIONS; i++) {
32-
buffer[i].size = (rand() * MAX_ALLOCATION_SIZE) / RAND_MAX;
32+
buffer[i].size =
33+
(size_t)((rand() / (double)RAND_MAX) * MAX_ALLOCATION_SIZE);
3334
buffer[i].ptr = umf_ba_linear_alloc(pool, buffer[i].size);
3435
UT_ASSERTne(buffer[i].ptr, NULL);
3536
memset(buffer[i].ptr, (i + TID) & 0xFF, buffer[i].size);

0 commit comments

Comments
 (0)