mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 09:58:03 +02:00
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:
@@ -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;
|
||||
|
||||
@@ -87,6 +87,7 @@ void ffInitWeatherOptions(FFWeatherOptions* options) {
|
||||
void ffDestroyWeatherOptions(FFWeatherOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
|
||||
ffStrbufDestroy(&options->location);
|
||||
ffStrbufDestroy(&options->outputFormat);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user