From c5a8950ad4d3a460d5789c66e402164ae8cea693 Mon Sep 17 00:00:00 2001 From: h4sht Date: Fri, 24 Jul 2026 02:39:07 +0200 Subject: [PATCH] Weather: fixes memory leak and replace aggressive exit(1) with proper error handling (#2474) - Add missing ffStrbufDestroy(&options->location) in ffDestroyWeatherOptions to prevent memory leak when location is set via config - Replace exit(1) in ffPrepareWeather with setting status to an error string, allowing the error to be properly propagated through the existing error mechanism Co-authored-by: tru3 --- src/detection/weather/weather.c | 4 ++-- src/modules/weather/weather.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/detection/weather/weather.c b/src/detection/weather/weather.c index 8a70a966a..0f65af8cf 100644 --- a/src/detection/weather/weather.c +++ b/src/detection/weather/weather.c @@ -7,8 +7,8 @@ static const char* status = FF_UNITIALIZED; void ffPrepareWeather(FFWeatherOptions* options) { if (status != FF_UNITIALIZED) { - fputs("Error: Weather module can only be used once due to internal limitations\n", stderr); - exit(1); + status = "Weather module can only be used once due to internal limitations"; + return; } state.timeout = options->timeout; diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index 6c156929d..414a18e7e 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -87,6 +87,7 @@ void ffInitWeatherOptions(FFWeatherOptions* options) { void ffDestroyWeatherOptions(FFWeatherOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); + ffStrbufDestroy(&options->location); ffStrbufDestroy(&options->outputFormat); }