gbranden pushed a commit to branch master
in repository groff.

commit 2f052525212cbbe6c96221d58e2bbbe6f77f7f6f
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Thu Jul 10 16:45:49 2025 -0500

    [pre-grohtml]: Slightly refactor (2/2).
    
    * src/preproc/html/pre-html.cpp (get_resolution, get_image_generator):
      Free `pathp` _after_ we've looped through all the lines in the file
      we've opened instead of before.  This is to to prepare for a change
      where we pass `pathp` to `get_line()` as a new argument.
---
 ChangeLog                     | 8 ++++++++
 src/preproc/html/pre-html.cpp | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4a0c9e1f0..f6fa960b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-07-10  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       * src/preproc/html/pre-html.cpp (get_resolution)
+       (get_image_generator): Slightly refactor.  Free `pathp` _after_
+       we've looped through all the lines in the file we've opened
+       instead of before.  This is to to prepare for a change where we
+       pass `pathp` to `get_line()` as a new argument.
+
 2025-07-10  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        * src/preproc/html/pre-html.cpp (get_line): Slightly refactor.
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index 9199a3c8d..111673164 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -315,12 +315,12 @@ static unsigned int get_resolution(void)
   f = font_path.open_file(devps_desc, &pathp);
   if (0 /* nullptr */ == f)
     fatal("cannot open file '%1': %2", devps_desc, strerror(errno));
-  free(pathp);
   // XXX: We should break out of this loop if we hit a "charset" line.
   // "This line and everything following it in the file are ignored."
   // (groff_font(5))
   while (get_line(f))
     (void) sscanf(linebuf, "res %u", &res);
+  free(pathp);
   fclose(f);
   return res;
 }
@@ -341,7 +341,6 @@ static char *get_image_generator(void)
   f = font_path.open_file(devhtml_desc, &pathp);
   if (0 /* nullptr */ == f)
     fatal("cannot open file '%1': %2", devhtml_desc, strerror(errno));
-  free(pathp);
   // XXX: We should break out of this loop if we hit a "charset" line.
   // "This line and everything following it in the file are ignored."
   // (groff_font(5))
@@ -362,6 +361,7 @@ static char *get_image_generator(void)
       generator = cursor;
     }
   }
+  free(pathp);
   fclose(f);
   return generator;
 }

_______________________________________________
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to