Prevent unneeded Strgrow in Strinsert_char

This commit is contained in:
Tatsuya Kinoshita
2021-03-04 23:46:21 +09:00
parent 9ff239b340
commit 13015ebcf6

2
Str.c
View File

@@ -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);