Fixed dangling pointer to random state array

The C library function initstate(), at least in macOS El Capitan, not only sets the state array given to it as the second argument, but also accesses the state array given to it in a previous call! (I don't know why, or if that behaviour is correct, but macOS seems to do that anyhow).
Therefore, we cannot pass a local variable to it. As soon as the player thread stops, it will be a dangling pointer, and when a new player thread is started afterwards, initstate() will dereference that dangling pointer with unforeseeable consequences.
This commit is contained in:
Belbo
2017-10-31 23:19:22 +01:00
parent a704b2fe0b
commit 39e122a4ff
+1 -1
View File
@@ -1481,7 +1481,7 @@ static void *player_thread_func(void *arg) {
// I think it's useful to keep this prime to prevent it from falling into a pattern with some
// other process.
char rnstate[256];
static char rnstate[256];
initstate(time(NULL), rnstate, 256);
signed short *inbuf, *tbuf, *silence;