# HG changeset patch # User Scoopta # Date 1735031893 28800 # Tue Dec 24 01:18:13 2024 -0800 # Node ID b8668b4d6d6d33e3de86ce3fa4331249bc0abc8b # Parent 4f3db4dbe36cc651f9bd7931a35dc7cbc489452c Added proper error handling for a failure of ftruncate() diff --git a/src/scpy_source.c b/src/scpy_source.c --- a/src/scpy_source.c +++ b/src/scpy_source.c @@ -239,7 +239,13 @@ this->frame->fd = shm_open("/wlrobs", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); shm_unlink("/wlrobs"); int err = ftruncate(this->frame->fd, stride * height); - if(err) {} + if(err < 0) { + perror("Unable to resize shm"); + zwlr_screencopy_frame_v1_destroy(frame); + close(this->frame->fd); + this->waiting = false; + return; + } this->frame->pool = wl_shm_create_pool(this->shm, this->frame->fd, stride * height); this->frame->buffer = wl_shm_pool_create_buffer(this->frame->pool, 0, width, height, stride, format); zwlr_screencopy_frame_v1_copy(frame, this->frame->buffer); @@ -274,7 +280,6 @@ wl_buffer_destroy(this->frame->buffer); wl_shm_pool_destroy(this->frame->pool); close(this->frame->fd); - shm_unlink("/wlrobs"); this->waiting = false; }