summaryrefslogtreecommitdiffstats
path: root/openbsd
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2023-07-28 13:06:14 +0200
committerBenny Baumann <BenBE@geshi.org>2023-07-28 13:06:14 +0200
commit1309c4b3d5335bd4a70123accb801ccbc609519d (patch)
treeffdfd2fe527b6dbe84a2e96df73ffc351372b412 /openbsd
parent914d92dc3a2f3d0f3065abf52ba3da557910ee76 (diff)
Avoid VLA on OpenBSD when reading swap information
Diffstat (limited to 'openbsd')
-rw-r--r--openbsd/OpenBSDMachine.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/openbsd/OpenBSDMachine.c b/openbsd/OpenBSDMachine.c
index e3e30990..e8ff9232 100644
--- a/openbsd/OpenBSDMachine.c
+++ b/openbsd/OpenBSDMachine.c
@@ -163,7 +163,7 @@ static void OpenBSDMachine_scanMemoryInfo(OpenBSDMachine* this) {
*/
int nswap = swapctl(SWAP_NSWAP, 0, 0);
if (nswap > 0) {
- struct swapent swdev[nswap];
+ struct swapent* swdev = xMallocArray(nswap, sizeof(struct swapent));
int rnswap = swapctl(SWAP_STATS, swdev, nswap);
/* Total things up */
@@ -177,6 +177,8 @@ static void OpenBSDMachine_scanMemoryInfo(OpenBSDMachine* this) {
super->totalSwap = total;
super->usedSwap = used;
+
+ free(swdev);
} else {
super->totalSwap = super->usedSwap = 0;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy