[PATCH 4/5] editor: Improve checks on delete add asserts
Bill Spitzak
spitzak at gmail.com
Thu May 30 08:00:19 PDT 2013
On 05/30/2013 04:57 AM, Jan Arne Petersen wrote:
> - if (entry->pending_commit.delete_index + length > text_length) {
> + if (length > text_length ||
> + entry->pending_commit.delete_index + length > text_length) {
This is to detect wrap-around of the unsigned values, right? This is
annoyingly complex to get right. Checking if delete_index > text_length
as well will fix it if text_length is less than the first value with the
high bit set. The real check is not much more complex but I don't want
to get it wrong here...
> fprintf(stderr, "Invalid length %d\n", length);
> entry->pending_commit.delete_length = 0;
I think it would be better to truncate it at text_length.
More information about the wayland-devel
mailing list