api: return error when starting a slice out of bounds.

This commit is contained in:
Nick Hynes 2015-06-16 20:07:03 -04:00 committed by Justin M. Keyes
parent 90b4276d67
commit 7475c1c0f7

View File

@ -179,6 +179,11 @@ void buffer_set_line_slice(Buffer buffer,
return; return;
} }
if (!inbounds(buf, start)) {
api_set_error(err, Validation, _("Index out of bounds"));
return;
}
start = normalize_index(buf, start) + (include_start ? 0 : 1); start = normalize_index(buf, start) + (include_start ? 0 : 1);
include_end = include_end || (end >= buf->b_ml.ml_line_count); include_end = include_end || (end >= buf->b_ml.ml_line_count);
end = normalize_index(buf, end) + (include_end ? 1 : 0); end = normalize_index(buf, end) + (include_end ? 1 : 0);