gbranden pushed a commit to branch master
in repository groff.
commit 963308be46fe0c28f037da44850c7a8942c65636
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jun 10 11:48:46 2026 -0500
[refer]: Handle heap memory more fastidiously.
* src/preproc/refer/command.cpp (input_item::~input_item): The storage
backing the `filename` pointer is allocated (via `strsave()`) by
malloc(3), not `new`, so free it with free(3), not `delete[]`.
---
ChangeLog | 7 +++++++
src/preproc/refer/command.cpp | 3 ++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index fcbabefec..00ddd30ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-06-10 G. Branden Robinson <[email protected]>
+
+ * src/preproc/refer/command.cpp (input_item::~input_item): The
+ storage backing the `filename` pointer is allocated (via
+ `strsave()`) by malloc(3), not `new`, so free it with free(3),
+ not `delete[]`.
+
2026-06-10 G. Branden Robinson <[email protected]>
* src/preproc/tbl/tests/\
diff --git a/src/preproc/refer/command.cpp b/src/preproc/refer/command.cpp
index 4ae2901bd..a657ab53e 100644
--- a/src/preproc/refer/command.cpp
+++ b/src/preproc/refer/command.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#endif
#include <stdcountof.h>
+#include <stdlib.h> // free()
#include "refer.h"
#include "refid.h"
@@ -57,7 +58,7 @@ input_item::input_item(string &s, const char *fn, int ln)
input_item::~input_item()
{
- delete[] filename;
+ free(filename);
}
inline int input_item::peek_char()
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit