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 <tru3@tru3.com>
This commit is contained in:
h4sht
2026-07-24 02:39:07 +02:00
committed by Carter Li
parent e9258cc5a8
commit 62fe9e1d11
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -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;
+1
View File
@@ -87,6 +87,7 @@ void ffInitWeatherOptions(FFWeatherOptions* options) {
void ffDestroyWeatherOptions(FFWeatherOptions* options) {
ffOptionDestroyModuleArg(&options->moduleArgs);
ffStrbufDestroy(&options->location);
ffStrbufDestroy(&options->outputFormat);
}