gbranden pushed a commit to branch master
in repository groff.

commit 0f1179c95ed2fd4074d940f0ef50fa74cd412fb4
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jun 10 12:21:45 2026 -0500

    [libgroff]: Add assert(3)ions.
    
    * src/libs/libgroff/string.cpp (string::operator=, string::grow1)
      (string::clear): Add assert(3)ion enforcing new invariant.
---
 ChangeLog                    | 6 ++++++
 src/libs/libgroff/string.cpp | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 5527d05c2..4e506cd15 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-06-10  G. Branden Robinson <[email protected]>
+
+       * src/libs/libgroff/string.cpp (string::operator=)
+       (string::grow1, string::clear): Add assert(3)ion enforcing new
+       invariant.
+
 2026-06-11  G. Branden Robinson <[email protected]>
 
        * src/libs/libgroff/string.cpp (sfree_alloc, srealloc): Be more
diff --git a/src/libs/libgroff/string.cpp b/src/libs/libgroff/string.cpp
index 796bd7bca..6fca589be 100644
--- a/src/libs/libgroff/string.cpp
+++ b/src/libs/libgroff/string.cpp
@@ -195,6 +195,7 @@ string::~string()
 string &string::operator=(const string &s)
 {
   ptr = sfree_alloc(ptr, sz, s.len, &sz);
+  assert(ptr != 0 /* nullptr */);
   len = s.len;
   if (len != 0)
     memcpy(ptr, s.ptr, len);
@@ -222,6 +223,7 @@ string &string::operator=(const char *p)
 string &string::operator=(char c)
 {
   ptr = sfree_alloc(ptr, sz, 1, &sz);
+  assert(ptr != 0 /* nullptr */);
   len = 1;
   *ptr = c;
   return *this;
@@ -241,6 +243,7 @@ void string::move(string &s)
 void string::grow1()
 {
   ptr = srealloc(ptr, sz, len, len + 1, &sz);
+  assert(ptr != 0 /* nullptr */);
 }
 
 string &string::operator+=(const char *p)
@@ -336,6 +339,7 @@ void string::set_length(size_t i)
 
 void string::clear()
 {
+  //assert(ptr != 0 /* nullptr */); // XXX: TODO: held up by refer(1)
   if (ptr != 0 /* nullptr */)
     memset(ptr, 0, sz);
   len = 0;

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to