From 8801053fc2c5b482d993593c97949b8ac029c65c Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 7 Sep 2024 15:52:04 -0700 Subject: vcr: more row overflow crash preventions There's still assumptions that everything in the hierarchy fits within the canvas... the Xlib stuff would clip all this behind the scenes, but vcr/headless mode doesn't have such guard rails. At some point I need to sit down and do a thorough pass in this vein... Fortunately most my headless use cases have the canvas configured appropriately. --- src/vcr.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/vcr.c b/src/vcr.c index 3fb9a9d..9a42e36 100644 --- a/src/vcr.c +++ b/src/vcr.c @@ -1124,6 +1124,9 @@ void vcr_mark_finish_line(vcr_t *vcr, vcr_layer_t layer, int row) /* FIXME: the layers in backend/vcr etc should be in a layer-indexable array */ assert(layer == VCR_LAYER_GRAPHA || layer == VCR_LAYER_GRAPHB); + if (row * VCR_ROW_HEIGHT >= vcr->height) + return; + switch (vcr->backend->type) { #ifdef USE_XLIB case VCR_BACKEND_TYPE_XLIB: { @@ -1555,6 +1558,9 @@ void vcr_stash_row(vcr_t *vcr, vcr_layer_t layer, int row) assert(layer == VCR_LAYER_GRAPHA || layer == VCR_LAYER_GRAPHB); /* for now we only support stashing graphs */ + if (row * VCR_ROW_HEIGHT >= vcr->height) + return; + switch (vcr->backend->type) { #ifdef USE_XLIB case VCR_BACKEND_TYPE_XLIB: { @@ -1610,6 +1616,9 @@ void vcr_unstash_row(vcr_t *vcr, vcr_layer_t layer, int row) assert(vcr->backend); assert(layer == VCR_LAYER_GRAPHA || layer == VCR_LAYER_GRAPHB); + if (row * VCR_ROW_HEIGHT >= vcr->height) + return; + switch (vcr->backend->type) { #ifdef USE_XLIB case VCR_BACKEND_TYPE_XLIB: { -- cgit v1.2.3