mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 09:25:49 +00:00
Don't declare a variable length array on the stack
This commit is contained in:
parent
6b0f1aecc5
commit
64771ab6bc
@ -204,9 +204,16 @@ static int sendMessageAndDiscardReply(short ptype, short paylen, const void* pay
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void lossStatsThreadFunc(void* context) {
|
static void lossStatsThreadFunc(void* context) {
|
||||||
char lossStatsPayload[payloadLengths[IDX_LOSS_STATS]];
|
char *lossStatsPayload;
|
||||||
BYTE_BUFFER byteBuffer;
|
BYTE_BUFFER byteBuffer;
|
||||||
|
|
||||||
|
lossStatsPayload = malloc(payloadLengths[IDX_LOSS_STATS]);
|
||||||
|
if (lossStatsPayload == NULL) {
|
||||||
|
Limelog("Loss stats thread terminating #0\n");
|
||||||
|
listenerCallbacks->connectionTerminated(LastSocketError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (!PltIsThreadInterrupted(&lossStatsThread)) {
|
while (!PltIsThreadInterrupted(&lossStatsThread)) {
|
||||||
// Construct the payload
|
// Construct the payload
|
||||||
BbInitializeWrappedBuffer(&byteBuffer, lossStatsPayload, 0, payloadLengths[IDX_LOSS_STATS], BYTE_ORDER_LITTLE);
|
BbInitializeWrappedBuffer(&byteBuffer, lossStatsPayload, 0, payloadLengths[IDX_LOSS_STATS], BYTE_ORDER_LITTLE);
|
||||||
@ -221,6 +228,7 @@ static void lossStatsThreadFunc(void* context) {
|
|||||||
// Send the message (and don't expect a response)
|
// Send the message (and don't expect a response)
|
||||||
if (!sendMessageAndForget(packetTypes[IDX_LOSS_STATS],
|
if (!sendMessageAndForget(packetTypes[IDX_LOSS_STATS],
|
||||||
payloadLengths[IDX_LOSS_STATS], lossStatsPayload)) {
|
payloadLengths[IDX_LOSS_STATS], lossStatsPayload)) {
|
||||||
|
free(lossStatsPayload);
|
||||||
Limelog("Loss stats thread terminating #1\n");
|
Limelog("Loss stats thread terminating #1\n");
|
||||||
listenerCallbacks->connectionTerminated(LastSocketError());
|
listenerCallbacks->connectionTerminated(LastSocketError());
|
||||||
return;
|
return;
|
||||||
@ -232,6 +240,8 @@ static void lossStatsThreadFunc(void* context) {
|
|||||||
// Wait a bit
|
// Wait a bit
|
||||||
PltSleepMs(LOSS_REPORT_INTERVAL_MS);
|
PltSleepMs(LOSS_REPORT_INTERVAL_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(lossStatsPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resyncThreadFunc(void* context) {
|
static void resyncThreadFunc(void* context) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user