From 13015ebcf62aeeeddc298710c7cd889281f49844 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Thu, 4 Mar 2021 23:46:21 +0900 Subject: Prevent unneeded Strgrow in Strinsert_char --- Str.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Str.c') diff --git a/Str.c b/Str.c index b4f1360..464b5a7 100644 --- a/Str.c +++ b/Str.c @@ -348,7 +348,7 @@ Strinsert_char(Str s, int pos, char c) { int i; STR_LENGTH_CHECK(s); - if (pos < 0) + if (pos < 0 || s->length < pos) return; if (s->length + 2 > s->area_size) Strgrow(s); -- cgit v1.2.3