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. --- ed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ed.c b/ed.c
index ad6c81a..16fbe04 100644
--- a/ed.c
+++ b/ed.c
@@ -1096,9 +1096,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;
--
2.37.3
