editor: Improve checks on delete add asserts
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
9eaa8e51ca
commit
895a128ce1
+5
-1
@@ -214,7 +214,8 @@ text_input_delete_surrounding_text(void *data,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->pending_commit.delete_index + length > text_length) {
|
if (length > text_length ||
|
||||||
|
entry->pending_commit.delete_index + length > text_length) {
|
||||||
fprintf(stderr, "Invalid length %d\n", length);
|
fprintf(stderr, "Invalid length %d\n", length);
|
||||||
entry->pending_commit.delete_length = 0;
|
entry->pending_commit.delete_length = 0;
|
||||||
return;
|
return;
|
||||||
@@ -837,6 +838,9 @@ text_entry_delete_text(struct text_entry *entry,
|
|||||||
{
|
{
|
||||||
uint32_t l;
|
uint32_t l;
|
||||||
|
|
||||||
|
assert(index <= strlen(entry->text));
|
||||||
|
assert(index + length <= strlen(entry->text));
|
||||||
|
assert(index + length >= length);
|
||||||
|
|
||||||
l = strlen(entry->text + index + length);
|
l = strlen(entry->text + index + length);
|
||||||
memmove(entry->text + index,
|
memmove(entry->text + index,
|
||||||
|
|||||||
Reference in New Issue
Block a user