ad-oliviero / uwufetch

A meme system info tool for Linux, based on nyan/uwu trend on r/linuxmasterrace.
GNU General Public License v3.0
747 stars 48 forks source link

fix replacing ignorecase with multiple things to replace #138

Closed Joshix-1 closed 2 years ago

Joshix-1 commented 2 years ago

2021-10-03_12-58

Joshix-1 commented 2 years ago

The replace function also uses recursion. On my system the pr worked. Without the recursion I don't think the problem is fixed, but I need to try it.

ad-oliviero commented 2 years ago

On both my PCs it works, I will try it also on a vm, just to be sure

Joshix-1 commented 2 years ago

The problem is that it doesn't replace multiple instances of the word. In my GPU info there is two times "Radeon" it only replaces the first one.

Joshix-1 commented 2 years ago

How did you get the segfault?

Joshix-1 commented 2 years ago

https://github.com/Joshix-1/uwufetch/blob/replacement-fix/uwufetch.c#L727-L743 works for me.

ad-oliviero commented 2 years ago

According to gdb it calls replace_ignorecase endlessly

Joshix-1 commented 2 years ago

What's the string? The following check should prevent the infinite recursion, like the similar check in the replace function should.

if (!(ch = strcasestr(original, search)))
    return;