Skip to content

Commit

Permalink
api: return error when starting a slice out of bounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
nhynes authored and justinmk committed Jul 11, 2015
1 parent 90b4276 commit 7475c1c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/nvim/api/buffer.c
Expand Up @@ -179,6 +179,11 @@ void buffer_set_line_slice(Buffer buffer,
return;
}

if (!inbounds(buf, start)) {
api_set_error(err, Validation, _("Index out of bounds"));
return;
}

start = normalize_index(buf, start) + (include_start ? 0 : 1);
include_end = include_end || (end >= buf->b_ml.ml_line_count);
end = normalize_index(buf, end) + (include_end ? 1 : 0);
Expand Down

0 comments on commit 7475c1c

Please sign in to comment.