Skip to content

local-ip-key leads to concatenated key for multiple interfaces #368

@RainerKuemmerle

Description

@RainerKuemmerle

General description of bug:

Using local-ip-key leads to concatenated key for multiple interfaces.
For example:
--local-ip-key "{}"

wlp3s0    192.168.2.119
wlp3s0enx482ae38072b2   192.168.2.112

I would have expected

wlp3s0    192.168.2.119
enx482ae38072b2   192.168.2.112

Often helpful questions:

  • Does the issue occur across multiple terminal emulators? Y
  • Does the issue occur across multiple shells? (bash, zsh, fish, etc) Y

Output of fastfetch --version:

fastfetch 1.8.0

I believe this is fixed by the following diff - I am new to the code base.

$ git diff
diff --git a/src/modules/localip.c b/src/modules/localip.c
index 89df099..0d63694 100644
--- a/src/modules/localip.c
+++ b/src/modules/localip.c
@@ -24,11 +24,10 @@ void ffPrintLocalIp(FFinstance* instance)
         goto exit;
     }
 
-    FFstrbuf key;
-    ffStrbufInit(&key);
-
     for(uint32_t i = 0; i < results.length; ++i)
     {
+        FFstrbuf key;
+        ffStrbufInit(&key);
         FFLocalIpResult* ip = (FFLocalIpResult*) ffListGet(&results, i);
 
         if(instance->config.localIP.key.length == 0)
@@ -60,10 +59,9 @@ void ffPrintLocalIp(FFinstance* instance)
 
         ffStrbufDestroy(&ip->name);
         ffStrbufDestroy(&ip->addr);
+        ffStrbufDestroy(&key);
     }
 
-    ffStrbufDestroy(&key);
-
 exit:
     ffListDestroy(&results);
 }

Please let me know if there is a misunderstanding on my end. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions