From 9a3909f8ba303999dc710232825d06d06925966c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 16 Feb 2023 17:19:43 +0800 Subject: [PATCH] Memory (Windows): check for error cases --- src/detection/memory/memory_windows.c | 6 +++++- src/detection/swap/swap_windows.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/detection/memory/memory_windows.c b/src/detection/memory/memory_windows.c index ef3153843..d639c2a73 100644 --- a/src/detection/memory/memory_windows.c +++ b/src/detection/memory/memory_windows.c @@ -5,7 +5,11 @@ void ffDetectMemory(FFMemoryStorage* ram) MEMORYSTATUSEX statex = { .dwLength = sizeof(statex), }; - GlobalMemoryStatusEx(&statex); + if (!GlobalMemoryStatusEx(&statex)) + { + ffStrbufAppendS(&ram->error, "GlobalMemoryStatusEx() failed"); + return; + } ram->bytesTotal = statex.ullTotalPhys; ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys; } diff --git a/src/detection/swap/swap_windows.cpp b/src/detection/swap/swap_windows.cpp index 224a3ce35..d7f910f95 100644 --- a/src/detection/swap/swap_windows.cpp +++ b/src/detection/swap/swap_windows.cpp @@ -23,7 +23,7 @@ void ffDetectSwap(FFMemoryStorage* swap) { if(!(pstart = (SYSTEM_PAGEFILE_INFORMATION*)realloc(pstart, size))) { - ffStrbufAppendF(&swap->error, "relloc(pstart, %lu) failed", size); + ffStrbufAppendF(&swap->error, "realloc(pstart, %lu) failed", size); return; } }