From dde8f7a5273ebd1fe9e6fa5c99f378f9651bb192 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 20 Jun 2020 07:17:06 +0200 Subject: [PATCH] libpspp/str.c (ds_splice_uninit): Add assertion --- src/libpspp/str.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libpspp/str.c b/src/libpspp/str.c index d855150b35..c227f7f698 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -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)); -- 2.30.2