diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2021-03-04 13:18:03 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2021-03-04 13:18:03 +0000 |
commit | e11bb2b868940d9390510b8b7bbd482f74f4baa7 (patch) | |
tree | d5b68d6432b1b21662b79fc38ca851efbedc8b99 | |
parent | Update ChangeLog (diff) | |
download | w3m-e11bb2b868940d9390510b8b7bbd482f74f4baa7.tar.gz w3m-e11bb2b868940d9390510b8b7bbd482f74f4baa7.zip |
Consider Strgrow overflow in Strinsert_char
-rw-r--r-- | Str.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -348,10 +348,12 @@ Strinsert_char(Str s, int pos, char c) { int i; STR_LENGTH_CHECK(s); - if (pos < 0 || s->length < pos) + if (pos < 0) return; if (s->length + 2 > s->area_size) Strgrow(s); + if (s->length < pos) + return; for (i = s->length; i > pos; i--) s->ptr[i] = s->ptr[i - 1]; s->ptr[++s->length] = '\0'; |