mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +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) {
|
||||
char lossStatsPayload[payloadLengths[IDX_LOSS_STATS]];
|
||||
char *lossStatsPayload;
|
||||
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)) {
|
||||
// Construct the payload
|
||||
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)
|
||||
if (!sendMessageAndForget(packetTypes[IDX_LOSS_STATS],
|
||||
payloadLengths[IDX_LOSS_STATS], lossStatsPayload)) {
|
||||
free(lossStatsPayload);
|
||||
Limelog("Loss stats thread terminating #1\n");
|
||||
listenerCallbacks->connectionTerminated(LastSocketError());
|
||||
return;
|
||||
@ -232,6 +240,8 @@ static void lossStatsThreadFunc(void* context) {
|
||||
// Wait a bit
|
||||
PltSleepMs(LOSS_REPORT_INTERVAL_MS);
|
||||
}
|
||||
|
||||
free(lossStatsPayload);
|
||||
}
|
||||
|
||||
static void resyncThreadFunc(void* context) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user