mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 09:58:03 +02:00
PublicIP: replaces exit(1) with proper error status
- Add missing ffStrbufDestroy(&options->outputColor) in ffDestroySeparatorOptions to prevent memory leak when outputColor is set via JSON config - Replace two exit(1) calls in ffPreparePublicIp with proper error status propagation, matching the pattern used in the weather module
This commit is contained in:
@@ -9,8 +9,8 @@ void ffPreparePublicIp(FFPublicIPOptions* options) {
|
||||
FFNetworkingState* state = &states[options->ipv6];
|
||||
const char** status = &statuses[options->ipv6];
|
||||
if (*status != FF_UNINITIALIZED) {
|
||||
fputs("Error: PublicIp module can only be used once due to internal limitations\n", stderr);
|
||||
exit(1);
|
||||
*status = "PublicIp module can only be used once due to internal limitations";
|
||||
return;
|
||||
}
|
||||
|
||||
state->timeout = options->timeout;
|
||||
@@ -25,8 +25,8 @@ void ffPreparePublicIp(FFPublicIPOptions* options) {
|
||||
uint32_t hostStartIndex = ffStrbufFirstIndexS(&host, "://");
|
||||
if (hostStartIndex < host.length) {
|
||||
if (hostStartIndex != 4 || !ffStrbufStartsWithIgnCaseS(&host, "http")) {
|
||||
fputs("Error: only http: protocol is supported. Use `Command` module with `curl` if needed\n", stderr);
|
||||
exit(1);
|
||||
*status = "Only http: protocol is supported. Use `Command` module with `curl` if needed";
|
||||
return;
|
||||
}
|
||||
ffStrbufSubstrAfter(&host, hostStartIndex + (uint32_t) (strlen("://") - 1));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user