1
0
mirror of git://git.suckless.org/sbase synced 2025-01-02 21:12:15 +00:00

ed: Avoid dangling pointer in getrhs()

If the string r.str is freed but error() is called then
next call will see a pointer that maybe it will try to free
because the call to error unwind the frame stack.
This commit is contained in:
Roberto E. Vargas Caballero 2023-11-29 15:47:51 +01:00 committed by k0ga
parent b089261c3a
commit aacfa18b79

2
ed.c
View File

@ -1102,9 +1102,9 @@ getrhs(int delim)
}
if (!strcmp("%", s.str)) {
free(s.str);
if (!rhs)
error("no previous substitution");
free(s.str);
} else {
free(rhs);
rhs = s.str;