Added proper error handling for a failure of ftruncate()
1 files changed, 7 insertions(+), 2 deletions(-)

M src/scpy_source.c
M src/scpy_source.c +7 -2
@@ 239,7 239,13 @@ static void buffer(void* data, struct zw
 	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 @@ static void failed(void* data, struct zw
 	wl_buffer_destroy(this->frame->buffer);
 	wl_shm_pool_destroy(this->frame->pool);
 	close(this->frame->fd);
-	shm_unlink("/wlrobs");
 	this->waiting = false;
 }