Fix a crash when displaying very large number of images

Fixes #1825
This commit is contained in:
Kovid Goyal 2019-07-23 10:18:09 +05:30
parent 14d703f5cc
commit 6a126fa18e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 2 deletions

View File

@ -56,6 +56,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- When using :opt:`strip_trailing_spaces` do not remove empty lines
(:iss:`1802`)
- Fix a crash when displaying very large number of images (:iss:`1825`)
0.14.2 [2019-06-09]
---------------------

View File

@ -260,7 +260,9 @@ find_or_create_image(GraphicsManager *self, uint32_t id, bool *existing) {
}
*existing = false;
ensure_space_for(self, images, Image, self->image_count + 1, images_capacity, 64, true);
return self->images + self->image_count++;
Image *ans = self->images + self->image_count++;
memset(ans, 0, sizeof(ans[0]));
return ans;
}
@ -490,7 +492,10 @@ handle_put_command(GraphicsManager *self, const GraphicsCommand *g, Cursor *c, b
break;
}
}
if (ref == NULL) ref = img->refs + img->refcnt++;
if (ref == NULL) {
ref = img->refs + img->refcnt++;
memset(ref, 0, sizeof(ref[0]));
}
img->atime = monotonic();
ref->src_x = g->x_offset; ref->src_y = g->y_offset; ref->src_width = g->width ? g->width : img->width; ref->src_height = g->height ? g->height : img->height;
ref->src_width = MIN(ref->src_width, img->width - (img->width > ref->src_x ? ref->src_x : img->width));
@ -563,6 +568,7 @@ grman_update_layers(GraphicsManager *self, unsigned int scrolled_by, float scree
if (ref->z_index < 0) self->num_of_negative_refs++; else self->num_of_positive_refs++;
ensure_space_for(self, render_data, ImageRenderData, self->count + 1, capacity, 64, true);
ImageRenderData *rd = self->render_data + self->count;
memset(rd, 0, sizeof(rd[0]));
set_vertex_data(rd, ref, &r);
self->count++;
rd->z_index = ref->z_index; rd->image_id = img->internal_id;