[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 08/08: [troff]: Fix unsafe-mode null pointer dereference.
From: |
G. Branden Robinson |
Subject: |
[groff] 08/08: [troff]: Fix unsafe-mode null pointer dereference. |
Date: |
Tue, 17 Sep 2024 10:18:36 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit e8ffda953c84c34c73101369f69cdc6630d788ff
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Sep 17 07:59:23 2024 -0500
[troff]: Fix unsafe-mode null pointer dereference.
* src/roff/troff/input.cpp (open_file): Fix unsafe-mode SEGV caused by
null pointer dereference. Problem introduced by me in commit
6d32f2492e, 13 September. Also add assertion; null `FILE` stream
pointers should not be getting stored in GNU troff's
`stream_dictionary`.
---
ChangeLog | 8 ++++++++
src/roff/troff/input.cpp | 14 +++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d860c7860..ce16fb55f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-09-17 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/input.cpp (open_file): Fix unsafe-mode SEGV
+ caused by null pointer dereference. Problem introduced by me in
+ commit 6d32f2492e, 13 September. Also add assertion; null
+ `FILE` stream pointers should not be getting stored in GNU
+ troff's `stream_dictionary`.
+
2024-09-17 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/input.cpp (report_color): Report color space
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 3a2f713f4..6de8078c6 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7282,11 +7282,15 @@ static void open_file(bool appending)
else {
grostream *oldgrost
= (grostream *)stream_dictionary.lookup(stream);
- FILE *oldfp = oldgrost->file;
- if (oldfp != 0 /* nullptr */ && (fclose(oldfp) != 0)) {
- error("cannot close file '%1' already associated with stream"
- " '%2': %3", filename.contents(), strerror(errno));
- return;
+ if (oldgrost != 0 /* nullptr */) {
+ FILE *oldfp = oldgrost->file;
+ assert(oldfp != 0 /* nullptr */);
+ if (oldfp != 0 /* nullptr */ && (fclose(oldfp) != 0)) {
+ error("cannot close file '%1' already associated with"
+ " stream '%2': %3", filename.contents(),
+ strerror(errno));
+ return;
+ }
}
grostream *grost = new grostream(filename.contents(), mode,
&*fp);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 08/08: [troff]: Fix unsafe-mode null pointer dereference.,
G. Branden Robinson <=