libpspp/str.c (ds_splice_uninit): Add assertion
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 20 Jun 2020 05:17:06 +0000 (07:17 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 20 Jun 2020 05:18:19 +0000 (07:18 +0200)
src/libpspp/str.c

index d855150b35f62530525d57e6d608adaa20df2f95..c227f7f6989da54c915b82884f6b6ee453a63ebf 100644 (file)
@@ -1,5 +1,6 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012, 2014 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012, 2014,
+   2020 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1510,6 +1511,9 @@ ds_splice_uninit (struct string *st,
     {
       if (new_len > old_len)
         ds_extend (st, ds_length (st) + (new_len - old_len));
+
+      assert (ds_length (st) >= ofs + old_len);
+
       memmove (ds_data (st) + (ofs + new_len),
                ds_data (st) + (ofs + old_len),
                ds_length (st) - (ofs + old_len));