From 780bc3f1d756f98a897d16bcad5061c8123a281e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gyuhwan=20Park=E2=98=85?= Date: Tue, 5 Sep 2023 12:11:54 +0900 Subject: [PATCH] fix: prevent division by zero when rectSize is RECT_SIZE_BYPASS_CREATE (0) --- XrdpUlalacaPrivate.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/XrdpUlalacaPrivate.cpp b/XrdpUlalacaPrivate.cpp index 97f7db7..70dd340 100644 --- a/XrdpUlalacaPrivate.cpp +++ b/XrdpUlalacaPrivate.cpp @@ -98,13 +98,15 @@ std::shared_ptr> XrdpUlalacaPrivate::createCopyRects( int rectSize ) const { auto blocks = std::make_shared>(); - blocks->reserve((_sessionSize.width * _sessionSize.height) / (rectSize * rectSize)); if (rectSize == RECT_SIZE_BYPASS_CREATE) { + blocks->reserve(dirtyRects.size()); std::copy(dirtyRects.begin(), dirtyRects.end(), std::back_insert_iterator(*blocks)); return std::move(blocks); } + blocks->reserve((_sessionSize.width * _sessionSize.height) / (rectSize * rectSize)); + int mapWidth = std::ceil((float) _sessionSize.width / (float) rectSize); int mapHeight = std::ceil((float) _sessionSize.height / (float) rectSize); int mapSize = mapWidth * mapHeight;