mirror of
https://github.com/tmux/tmux.git
synced 2026-05-30 14:16:18 +00:00
Add some checks on line size to avoid underflow, from san65384 at gmail
dot com in GitHub issue 4955.
This commit is contained in:
@@ -301,6 +301,8 @@ mode_tree_clear_tagged(struct mode_tree_list *mtl)
|
|||||||
void
|
void
|
||||||
mode_tree_up(struct mode_tree_data *mtd, int wrap)
|
mode_tree_up(struct mode_tree_data *mtd, int wrap)
|
||||||
{
|
{
|
||||||
|
if (mtd->line_size == 0)
|
||||||
|
return;
|
||||||
if (mtd->current == 0) {
|
if (mtd->current == 0) {
|
||||||
if (wrap) {
|
if (wrap) {
|
||||||
mtd->current = mtd->line_size - 1;
|
mtd->current = mtd->line_size - 1;
|
||||||
@@ -317,6 +319,8 @@ mode_tree_up(struct mode_tree_data *mtd, int wrap)
|
|||||||
int
|
int
|
||||||
mode_tree_down(struct mode_tree_data *mtd, int wrap)
|
mode_tree_down(struct mode_tree_data *mtd, int wrap)
|
||||||
{
|
{
|
||||||
|
if (mtd->line_size == 0)
|
||||||
|
return (0);
|
||||||
if (mtd->current == mtd->line_size - 1) {
|
if (mtd->current == mtd->line_size - 1) {
|
||||||
if (wrap) {
|
if (wrap) {
|
||||||
mtd->current = 0;
|
mtd->current = 0;
|
||||||
@@ -363,6 +367,8 @@ mode_tree_swap(struct mode_tree_data *mtd, int direction)
|
|||||||
void *
|
void *
|
||||||
mode_tree_get_current(struct mode_tree_data *mtd)
|
mode_tree_get_current(struct mode_tree_data *mtd)
|
||||||
{
|
{
|
||||||
|
if (mtd->line_size == 0)
|
||||||
|
return (NULL);
|
||||||
return (mtd->line_list[mtd->current].item->itemdata);
|
return (mtd->line_list[mtd->current].item->itemdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,6 +439,8 @@ mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
if (mtd->current >= mtd->line_size) {
|
if (mtd->current >= mtd->line_size) {
|
||||||
|
if (mtd->line_size == 0)
|
||||||
|
return (0);
|
||||||
mtd->current = mtd->line_size - 1;
|
mtd->current = mtd->line_size - 1;
|
||||||
if (mtd->current > mtd->height - 1)
|
if (mtd->current > mtd->height - 1)
|
||||||
mtd->offset = mtd->current - mtd->height + 1;
|
mtd->offset = mtd->current - mtd->height + 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user