From c3970154d6e1a6708c79dc0e43fd2d163a5ecde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 1 Mar 2024 10:41:42 +0800 Subject: [PATCH] GPU (Linux): fix memleaks --- src/detection/gpu/gpu_linux.c | 2 +- src/modules/physicaldisk/physicaldisk.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index d1fb13e4f..3cc6bdcdd 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -78,7 +78,7 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) //https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-pci const char* pciDirPath = "/sys/bus/pci/devices/"; - DIR* dirp = opendir(pciDirPath); + FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDirPath); if(dirp == NULL) return "Failed to open `/sys/bus/pci/devices/`"; diff --git a/src/modules/physicaldisk/physicaldisk.c b/src/modules/physicaldisk/physicaldisk.c index 7bb9187cb..96d0c2c12 100644 --- a/src/modules/physicaldisk/physicaldisk.c +++ b/src/modules/physicaldisk/physicaldisk.c @@ -130,6 +130,7 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options) ffStrbufDestroy(&dev->interconnect); ffStrbufDestroy(&dev->devPath); ffStrbufDestroy(&dev->serial); + ffStrbufDestroy(&dev->revision); } } @@ -244,6 +245,8 @@ void ffGeneratePhysicalDiskJsonResult(FFPhysicalDiskOptions* options, yyjson_mut ffStrbufDestroy(&dev->name); ffStrbufDestroy(&dev->interconnect); ffStrbufDestroy(&dev->devPath); + ffStrbufDestroy(&dev->serial); + ffStrbufDestroy(&dev->revision); } }