groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/36: [tbl]: Fix code hygiene nit.


From: G. Branden Robinson
Subject: [groff] 01/36: [tbl]: Fix code hygiene nit.
Date: Tue, 17 Jan 2023 20:45:09 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 773df71bd7b0148b6a443a8def1f61c9da272c08
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Jan 11 12:14:09 2023 -0600

    [tbl]: Fix code hygiene nit.
    
    * src/preproc/tbl/main.cpp (process_format): Fix code hygiene nit:
      nullify `list` pointer after freeing its target.
---
 ChangeLog                | 5 +++++
 src/preproc/tbl/main.cpp | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 35c7c266a..e1235a2f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-01-11  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/preproc/tbl/main.cpp (process_format): Fix code hygiene
+       nit: nullify `list` pointer after freeing its target.
+
 2023-01-11  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [tbl]: Really fix Savannah #63449.
diff --git a/src/preproc/tbl/main.cpp b/src/preproc/tbl/main.cpp
index 516d1b649..1daa629bd 100644
--- a/src/preproc/tbl/main.cpp
+++ b/src/preproc/tbl/main.cpp
@@ -785,6 +785,7 @@ format *process_format(table_input &in, options *opt,
        error("end of input while processing table format"
              " specification");
        free_input_entry_format_list(list);
+       list = 0 /* nullptr */;
        return 0;
       }
       switch (c) {
@@ -849,6 +850,7 @@ format *process_format(table_input &in, options *opt,
          break;
        error("invalid column classifier '%1'", char(c));
        free_input_entry_format_list(list);
+       list = 0 /* nullptr */;
        return 0;
       }
       if (got_period)
@@ -1062,6 +1064,7 @@ format *process_format(table_input &in, options *opt,
            if (c == EOF || c == '\n') {
              error("'w' column modifier missing closing parenthesis");
              free_input_entry_format_list(list);
+             list = 0 /* nullptr */;
              return 0;
            }
            list->width += c;
@@ -1137,12 +1140,14 @@ format *process_format(table_input &in, options *opt,
     if (c != '\n') {
       error("'.' is not the last character of the table format");
       free_input_entry_format_list(list);
+      list = 0 /* nullptr */;
       return 0;
     }
   }
   if (!list) {
     error("table format specification is empty");
     free_input_entry_format_list(list);
+    list = 0 /* nullptr */;
     return 0;
   }
   list->is_last_column = true;
@@ -1182,6 +1187,7 @@ format *process_format(table_input &in, options *opt,
     if (ncolumns > current_format->ncolumns) {
       error("cannot increase the number of columns in a continued format");
       free_input_entry_format_list(list);
+      list = 0 /* nullptr */;
       return 0;
     }
     f = current_format;
@@ -1239,6 +1245,7 @@ format *process_format(table_input &in, options *opt,
       col++;
   }
   free_input_entry_format_list(list);
+  list = 0 /* nullptr */;
   for (col = 0; col < ncolumns; col++) {
     entry_format *e = f->entry[f->nrows - 1] + col;
     if (e->type != FORMAT_HLINE



reply via email to

[Prev in Thread] Current Thread [Next in Thread]