Skip to content

Commit c3f9e55

Browse files
committed
noise pattern: use rand_s in Windows
`-e 16384x1024.p_u8.noise.tst` generates visual patterns in the noise
1 parent d273445 commit c3f9e55

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/utils/image_delegate.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <assert.h>
2929
#include <stdbool.h>
3030
#include <stdio.h>
31+
#define _CRT_RAND_S
3132
#include <stdlib.h>
3233
#include <string.h>
3334

@@ -572,9 +573,15 @@ tst_image_load_delegate(const char* filename, size_t* image_size, void** image_d
572573
break;
573574
}
574575
case TST_NOISE: {
575-
char* data = *image_data;
576+
unsigned char* data = *image_data;
576577
for ( unsigned i = 0; i < *image_size; ++i ) {
577-
data[i] = rand();
578+
unsigned val = 0;
579+
#ifdef WIN32
580+
rand_s(&val);
581+
#else
582+
val = rand();
583+
#endif
584+
data[i] = val % 256;
578585
}
579586
break;
580587
}

0 commit comments

Comments
 (0)