groff-commit
[Top][All Lists]
Advanced

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

[groff] 01/03: [libgroff]: (relocatep) Add assertion.


From: G. Branden Robinson
Subject: [groff] 01/03: [libgroff]: (relocatep) Add assertion.
Date: Tue, 5 Jan 2021 23:55:37 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 89c98409d32d01867e6f7cb7ab61efaf7b1da67e
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Jan 6 15:34:50 2021 +1100

    [libgroff]: (relocatep) Add assertion.
    
    * src/libs/libgroff/relocate.cpp (relocatep): Add assertion to identify
      logic error if `curr_prefix` is unexpectedly a null pointer.  See
      <https://savannah.gnu.org/bugs/?55475>.
---
 ChangeLog                      | 6 ++++++
 src/libs/libgroff/relocate.cpp | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 294ab0b..03a23a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-01-06  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/libs/libgroff/relocate.cpp (relocatep): Add assertion to
+       identify logic error if `curr_prefix` is unexpectedly a null
+       pointer.  See <https://savannah.gnu.org/bugs/?55475>.
+
 2021-01-06  Colin Watson <cjwatson@debian.org>
 
        * contrib/glilypond/glilypond.pl:
diff --git a/src/libs/libgroff/relocate.cpp b/src/libs/libgroff/relocate.cpp
index 393fbfc..e505bdf 100644
--- a/src/libs/libgroff/relocate.cpp
+++ b/src/libs/libgroff/relocate.cpp
@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <stdlib.h>
 
+#include "assert.h"
 #include "defs.h"
 #include "posix.h"
 #include "nonposix.h"
@@ -212,6 +213,7 @@ char *relocatep(const char *path)
   size_t relative_path_len = strlen(relative_path);
   char *relocated_path = (char *)malloc(curr_prefix_len
                                        + relative_path_len + 1);
+  assert(0 != curr_prefix);
   strcpy(relocated_path, curr_prefix);
   strcat(relocated_path, relative_path);
 #if DEBUG



reply via email to

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