[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 03/03: [pic]: Update input file name correctly.
From: |
G. Branden Robinson |
Subject: |
[groff] 03/03: [pic]: Update input file name correctly. |
Date: |
Tue, 28 Sep 2021 02:41:13 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 423e3c0b45a59c5476a2adc95bd38426a40456f3
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Sep 28 16:05:36 2021 +1000
[pic]: Update input file name correctly.
* src/preproc/pic/troff.cpp (troff_output::set_location): Copy the
inbound file name argument with `strdup()` and store pointer to this
copy in `last_filename` instead of aliasing argument.
(troff_output::~troff_output): `free()` the memory allocated by
`strdup()` in destructor.
Fixes <https://savannah.gnu.org/bugs/?61206>. Pointer assignment
instead of a string copy was being performed, which means that after its
initial assignment, `last_filename` always shared its value ultimately
with the `current_filename` pointer (a libgroff symbol), so `strcmp()`
was always being performed on identical pointers. Problem appears to
date back 30+ years, to the dawn of our repo history.
---
ChangeLog | 18 ++++++++++++++++++
src/preproc/pic/troff.cpp | 10 ++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c909b30..8d9aac8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2021-09-28 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [pic]: Update input file name correctly.
+
+ * src/preproc/pic/troff.cpp (troff_output::set_location): Copy
+ the inbound file name argument with `strdup()` and store pointer
+ to this copy in `last_filename` instead of aliasing argument.
+ (troff_output::~troff_output): `free()` the memory allocated by
+ `strdup()` in destructor.
+
+ Fixes <https://savannah.gnu.org/bugs/?61206>. Pointer
+ assignment instead of a string copy was being performed, which
+ means that after its initial assignment, `last_filename` always
+ shared its value ultimately with the `current_filename` pointer
+ {a libgroff symbol}, so `strcmp()` was always being performed on
+ identical pointers. Problem appears to date back 30+ years, to
+ the dawn of our repo history.
+
2021-09-24 G. Branden Robinson <g.branden.robinson@gmail.com>
* font/devlj4/S: Make font name consistent with file name.
diff --git a/src/preproc/pic/troff.cpp b/src/preproc/pic/troff.cpp
index 8955b30..3ccd681 100644
--- a/src/preproc/pic/troff.cpp
+++ b/src/preproc/pic/troff.cpp
@@ -1,4 +1,3 @@
-// -*- C++ -*-
/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -254,6 +253,7 @@ troff_output::troff_output()
troff_output::~troff_output()
{
+ free((char *)last_filename);
}
inline position troff_output::transform(const position &pos)
@@ -560,6 +560,12 @@ void troff_output::set_location(const char *s, int n)
printf(".lf %d\n", n);
else {
printf(".lf %d %s\n", n, s);
- last_filename = s;
+ last_filename = strdup(s);
}
}
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 03/03: [pic]: Update input file name correctly.,
G. Branden Robinson <=