Update of bug #68897 (group groff):
Status: Confirmed => In Progress
Planned Release: None => 1.26.0
Summary: [tbl] SEGV when continued table format is invalid =>
[PATCH] [tbl] SEGV when continued table format is invalid
_______________________________________________________
Follow-up Comment #2:
The patch likely won't apply to 1.25.0 without fuzz. I saw issues and got out
my janitorial broom.
commit 259681debe83c77202edb90999f3f8645721b6ed
Author: G. Branden Robinson <[email protected]>
Date: Mon Nov 9 07:10:28 2026 -0600
[tbl]: Fix Savannah #68897.
* src/preproc/tbl/main.cpp (process_format): Stop deleting the `format`
passed in as an argument if rejecting table description because its
final row definition contains only horizontal rules. I can't improve
on Dickson Wu's analysis (slightly recast).
"In src/preproc/tbl/main.cpp (1.25.0), `process_table()` owns
the first format ... [Upon] `.T&`, `process_data()` hands that
same object back to `process_format()` as `current_format`
{line 1617}, and `process_format()` keeps extending it in
place (`f = current_format;`, line 1254). The all-lines check
then deletes it ... `process_data()` gives up and returns [a]
null [pointer], and `process_table()` reaches `delete fmt`
with a dangling pointer. The other continued-format error
path, "cannot increase the number of columns", already returns
without deleting. Only this one gets ownership wrong."
Remedy by deleting the deletion of `f` on the "all-lines" error path.
For me, using a GCC 12 ASAN build, this resolves the heap-use-after-
free and does not introduce a memory leak.
Fixes <https://savannah.gnu.org/bugs/?68897>. Thanks to Dickson Wu for
the report; a cogent analysis; and a plausible, cautious recommended
fix. I went with a different one, doing nothing with `f` on the error
path.
ANNOUNCE: Acknowledge Dickson.
diff --git a/ANNOUNCE b/ANNOUNCE
index 9b08647b8..2bc62dd14 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -229,3 +229,4 @@ of this release.
instance with "grep -i -A1 thanks ChangeLog". A manual merge of
similar from the contrib/ change log files may also be necessary. ]]
+Dickson Wu
diff --git a/ChangeLog b/ChangeLog
index ada61775a..212361b88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2026-11-09 G. Branden Robinson <[email protected]>
+
+ * src/preproc/tbl/main.cpp (process_format): Stop deleting the
+ `format` passed in as an argument if rejecting table description
+ because its final row definition contains only horizontal rules.
+ I can't improve on Dickson Wu's analysis (slightly recast).
+ "In src/preproc/tbl/main.cpp (1.25.0), `process_table()` owns
+ the first format ... [Upon] `.T&`, `process_data()` hands that
+ same object back to `process_format()` as `current_format`
+ {line 1617}, and `process_format()` keeps extending it in
+ place (`f = current_format;`, line 1254). The all-lines check
+ then deletes it ... `process_data()` gives up and returns [a]
+ null [pointer], and `process_table()` reaches `delete fmt`
+ with a dangling pointer. The other continued-format error
+ path, "cannot increase the number of columns", already returns
+ without deleting. Only this one gets ownership wrong."
+ Remedy by deleting the deletion of `f` on the "all-lines" error
+ path. For me, using a GCC 12 ASAN build, this resolves the
+ heap-use-after-free and does not introduce a memory leak.
+
+ Fixes <https://savannah.gnu.org/bugs/?68897>. Thanks to Dickson
+ Wu for the report; a cogent analysis; and a plausible, cautious
+ recommended fix. I went with a different one, doing nothing
+ with `f` on the error path.
+
2026-11-09 G. Branden Robinson <[email protected]>
[tbl]: Regression-test Savannah #68897.
diff --git a/src/preproc/tbl/main.cpp b/src/preproc/tbl/main.cpp
index b33d5e736..e66fad189 100644
--- a/src/preproc/tbl/main.cpp
+++ b/src/preproc/tbl/main.cpp
@@ -1319,7 +1319,6 @@ static format *process_format(table_input &in, options
*opt,
if (col >= ncolumns) {
error("final row definition in table description"
" cannot contain only horizontal rules ('-', '_', '=')");
- delete f;
return 0 /* nullptr */;
}
if (have_expand && (opt->flags & table::EXPAND)) {
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68897>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
