[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 12/38: [groff]: Fix SEGV when exiting gxditview.
From: |
G. Branden Robinson |
Subject: |
[groff] 12/38: [groff]: Fix SEGV when exiting gxditview. |
Date: |
Mon, 3 Oct 2022 01:42:56 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 9d408e5ce0f2e5e639142d33b8292778e954bfb4
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Sep 28 17:01:08 2022 -0500
[groff]: Fix SEGV when exiting gxditview.
* src/roff/groff/groff.cpp (main): Fix SEGV when exiting gxditview. The
`postdriver` pointer always referred to allocated memory except when
the `-X` option was given; it was then assigned the address of a
#defined string literal. It was thus statically allocated and an
error to attempt to `free()` it. Duplicate the string on the heap
instead so that we can clean up uniformly regardless of postprocessor.
Problem caused by me when introducing `xexit()` in commit 6769e56aab,
20 June.
---
ChangeLog | 11 +++++++++++
src/roff/groff/groff.cpp | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index de4a0c22c..75702ae39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-09-28 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/groff/groff.cpp (main): Fix SEGV when exiting
+ gxditview. The `postdriver` pointer always referred to
+ allocated memory except when the `-X` option was given; it was
+ then assigned the address of a #defined string literal. It was
+ thus statically allocated and an error to attempt to `free()`
+ it. Duplicate the string on the heap instead so that we can
+ clean up uniformly regardless of postprocessor. Problem caused
+ by me when introducing `xexit()` in commit 6769e56aab, 20 June.
+
2022-09-28 G. Branden Robinson <g.branden.robinson@gmail.com>
* tmac/e.tmac (@o, n2, sk (f, ++): Consistently call `@err`
diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp
index b9c9f4166..1991f5a02 100644
--- a/src/roff/groff/groff.cpp
+++ b/src/roff/groff/groff.cpp
@@ -398,7 +398,7 @@ int main(int argc, char **argv)
const char *real_driver = 0 /* nullptr */;
if (Xflag) {
real_driver = postdriver;
- postdriver = (char *)GXDITVIEW;
+ postdriver = xstrdup(GXDITVIEW); // so we can free() it in xexit()
commands[TROFF_INDEX].append_arg("-r" XREG "=", "1");
}
if (postdriver)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 12/38: [groff]: Fix SEGV when exiting gxditview.,
G. Branden Robinson <=