{"action":"opened","number":2443,"pull_request":{"url":"https://api.github.com/repos/FreeRDP/FreeRDP/pulls/2443","id":31621313,"html_url":"https://github.com/FreeRDP/FreeRDP/pull/2443","diff_url":"https://github.com/FreeRDP/FreeRDP/pull/2443.diff","patch_url":"https://github.com/FreeRDP/FreeRDP/pull/2443.patch","issue_url":"https://api.github.com/repos/FreeRDP/FreeRDP/issues/2443","number":2443,"state":"open","locked":false,"title":"Incorrect extents calculation in region16_intersect_rect (libfreerdp/codec/region.c)","user":{"login":"realjiangms","id":4299660,"avatar_url":"https://avatars.githubusercontent.com/u/4299660?v=3","gravatar_id":"","url":"https://api.github.com/users/realjiangms","html_url":"https://github.com/realjiangms","followers_url":"https://api.github.com/users/realjiangms/followers","following_url":"https://api.github.com/users/realjiangms/following{/other_user}","gists_url":"https://api.github.com/users/realjiangms/gists{/gist_id}","starred_url":"https://api.github.com/users/realjiangms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realjiangms/subscriptions","organizations_url":"https://api.github.com/users/realjiangms/orgs","repos_url":"https://api.github.com/users/realjiangms/repos","events_url":"https://api.github.com/users/realjiangms/events{/privacy}","received_events_url":"https://api.github.com/users/realjiangms/received_events","type":"User","site_admin":false},"body":"There's an issue in libfreerdp/codec/region.c. When there's more than 2 rectangles in the region structure, region16_intersect_rect would calculate extents by all 'intersected' sub rectangles.\r\nBut it always extend the extents to (0,0) because it initialize the new extents as (0,0,0,0) and union later rectangles with this empty point by simple MIN/MAX calculation.\r\n\r\nIn addition, the semantics of rectangle_is_empty is also wrong.\r\n\r\nA fix could be as following:\r\n\r\n```diff\r\ndiff --git a/libfreerdp/codec/region.c b/libfreerdp/codec/region.c\r\nindex 95ce193..739b655 100644\r\n--- a/libfreerdp/codec/region.c\r\n+++ b/libfreerdp/codec/region.c\r\n@@ -132,7 +132,7 @@ static RECTANGLE_16 *region16_extents_noconst(REGION16 *region)\r\n\r\n BOOL rectangle_is_empty(const RECTANGLE_16 *rect)\r\n {\r\n-   return (rect->left + rect->top + rect->right + rect->bottom) ? TRUE : FALSE;\r\n+   return ((rect->left == rect->right) || (rect->top == rect->bottom)) ? TRUE : FALSE;\r\n }\r\n\r\n BOOL region16_is_empty(const REGION16 *region)\r\n@@ -770,10 +770,17 @@ BOOL region16_intersect_rect(REGION16 *dst, const REGION16 *src, const RECTANGLE\r\n            usedRects++;\r\n            dstPtr++;\r\n\r\n-           newExtents.top = MIN(common.top, newExtents.top);\r\n-           newExtents.left = MIN(common.left, newExtents.left);\r\n-           newExtents.bottom = MAX(common.bottom, newExtents.bottom);\r\n-           newExtents.right = MAX(common.right, newExtents.right);\r\n+            if (rectangle_is_empty(&newExtents))\r\n+            {\r\n+                newExtents = common;\r\n+            }\r\n+            else\r\n+            {\r\n+                newExtents.top = MIN(common.top, newExtents.top);\r\n+                newExtents.left = MIN(common.left, newExtents.left);\r\n+                newExtents.bottom = MAX(common.bottom, newExtents.bottom);\r\n+                newExtents.right = MAX(common.right, newExtents.right);\r\n+            }\r\n        }\r\n    }\r\n```\r\n","created_at":"2015-03-20T15:04:12Z","updated_at":"2015-03-20T15:04:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FreeRDP/FreeRDP/pulls/2443/commits","review_comments_url":"https://api.github.com/repos/FreeRDP/FreeRDP/pulls/2443/comments","review_comment_url":"https://api.github.com/repos/FreeRDP/FreeRDP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FreeRDP/FreeRDP/issues/2443/comments","statuses_url":"https://api.github.com/repos/FreeRDP/FreeRDP/statuses/f94935224c49f332c3f69168e1c1a2359f24b310","head":{"label":"realjiangms:fix_region","ref":"fix_region","sha":"f94935224c49f332c3f69168e1c1a2359f24b310","user":{"login":"realjiangms","id":4299660,"avatar_url":"https://avatars.githubusercontent.com/u/4299660?v=3","gravatar_id":"","url":"https://api.github.com/users/realjiangms","html_url":"https://github.com/realjiangms","followers_url":"https://api.github.com/users/realjiangms/followers","following_url":"https://api.github.com/users/realjiangms/following{/other_user}","gists_url":"https://api.github.com/users/realjiangms/gists{/gist_id}","starred_url":"https://api.github.com/users/realjiangms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realjiangms/subscriptions","organizations_url":"https://api.github.com/users/realjiangms/orgs","repos_url":"https://api.github.com/users/realjiangms/repos","events_url":"https://api.github.com/users/realjiangms/events{/privacy}","received_events_url":"https://api.github.com/users/realjiangms/received_events","type":"User","site_admin":false},"repo":{"id":31845483,"name":"FreeRDP","full_name":"realjiangms/FreeRDP","owner":{"login":"realjiangms","id":4299660,"avatar_url":"https://avatars.githubusercontent.com/u/4299660?v=3","gravatar_id":"","url":"https://api.github.com/users/realjiangms","html_url":"https://github.com/realjiangms","followers_url":"https://api.github.com/users/realjiangms/followers","following_url":"https://api.github.com/users/realjiangms/following{/other_user}","gists_url":"https://api.github.com/users/realjiangms/gists{/gist_id}","starred_url":"https://api.github.com/users/realjiangms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realjiangms/subscriptions","organizations_url":"https://api.github.com/users/realjiangms/orgs","repos_url":"https://api.github.com/users/realjiangms/repos","events_url":"https://api.github.com/users/realjiangms/events{/privacy}","received_events_url":"https://api.github.com/users/realjiangms/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/realjiangms/FreeRDP","description":"FreeRDP is a free remote desktop protocol client","fork":true,"url":"https://api.github.com/repos/realjiangms/FreeRDP","forks_url":"https://api.github.com/repos/realjiangms/FreeRDP/forks","keys_url":"https://api.github.com/repos/realjiangms/FreeRDP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/realjiangms/FreeRDP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/realjiangms/FreeRDP/teams","hooks_url":"https://api.github.com/repos/realjiangms/FreeRDP/hooks","issue_events_url":"https://api.github.com/repos/realjiangms/FreeRDP/issues/events{/number}","events_url":"https://api.github.com/repos/realjiangms/FreeRDP/events","assignees_url":"https://api.github.com/repos/realjiangms/FreeRDP/assignees{/user}","branches_url":"https://api.github.com/repos/realjiangms/FreeRDP/branches{/branch}","tags_url":"https://api.github.com/repos/realjiangms/FreeRDP/tags","blobs_url":"https://api.github.com/repos/realjiangms/FreeRDP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/realjiangms/FreeRDP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/realjiangms/FreeRDP/git/refs{/sha}","trees_url":"https://api.github.com/repos/realjiangms/FreeRDP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/realjiangms/FreeRDP/statuses/{sha}","languages_url":"https://api.github.com/repos/realjiangms/FreeRDP/languages","stargazers_url":"https://api.github.com/repos/realjiangms/FreeRDP/stargazers","contributors_url":"https://api.github.com/repos/realjiangms/FreeRDP/contributors","subscribers_url":"https://api.github.com/repos/realjiangms/FreeRDP/subscribers","subscription_url":"https://api.github.com/repos/realjiangms/FreeRDP/subscription","commits_url":"https://api.github.com/repos/realjiangms/FreeRDP/commits{/sha}","git_commits_url":"https://api.github.com/repos/realjiangms/FreeRDP/git/commits{/sha}","comments_url":"https://api.github.com/repos/realjiangms/FreeRDP/comments{/number}","issue_comment_url":"https://api.github.com/repos/realjiangms/FreeRDP/issues/comments{/number}","contents_url":"https://api.github.com/repos/realjiangms/FreeRDP/contents/{+path}","compare_url":"https://api.github.com/repos/realjiangms/FreeRDP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/realjiangms/FreeRDP/merges","archive_url":"https://api.github.com/repos/realjiangms/FreeRDP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/realjiangms/FreeRDP/downloads","issues_url":"https://api.github.com/repos/realjiangms/FreeRDP/issues{/number}","pulls_url":"https://api.github.com/repos/realjiangms/FreeRDP/pulls{/number}","milestones_url":"https://api.github.com/repos/realjiangms/FreeRDP/milestones{/number}","notifications_url":"https://api.github.com/repos/realjiangms/FreeRDP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/realjiangms/FreeRDP/labels{/name}","releases_url":"https://api.github.com/repos/realjiangms/FreeRDP/releases{/id}","created_at":"2015-03-08T10:08:37Z","updated_at":"2015-03-08T10:08:46Z","pushed_at":"2015-03-20T15:01:36Z","git_url":"git://github.com/realjiangms/FreeRDP.git","ssh_url":"git@github.com:realjiangms/FreeRDP.git","clone_url":"https://github.com/realjiangms/FreeRDP.git","svn_url":"https://github.com/realjiangms/FreeRDP","homepage":"http://www.freerdp.com/","size":26569,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"FreeRDP:master","ref":"master","sha":"3a2a91522195c03c54499be322b19e2d19cab902","user":{"login":"FreeRDP","id":663376,"avatar_url":"https://avatars.githubusercontent.com/u/663376?v=3","gravatar_id":"","url":"https://api.github.com/users/FreeRDP","html_url":"https://github.com/FreeRDP","followers_url":"https://api.github.com/users/FreeRDP/followers","following_url":"https://api.github.com/users/FreeRDP/following{/other_user}","gists_url":"https://api.github.com/users/FreeRDP/gists{/gist_id}","starred_url":"https://api.github.com/users/FreeRDP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FreeRDP/subscriptions","organizations_url":"https://api.github.com/users/FreeRDP/orgs","repos_url":"https://api.github.com/users/FreeRDP/repos","events_url":"https://api.github.com/users/FreeRDP/events{/privacy}","received_events_url":"https://api.github.com/users/FreeRDP/received_events","type":"Organization","site_admin":false},"repo":{"id":1979797,"name":"FreeRDP","full_name":"FreeRDP/FreeRDP","owner":{"login":"FreeRDP","id":663376,"avatar_url":"https://avatars.githubusercontent.com/u/663376?v=3","gravatar_id":"","url":"https://api.github.com/users/FreeRDP","html_url":"https://github.com/FreeRDP","followers_url":"https://api.github.com/users/FreeRDP/followers","following_url":"https://api.github.com/users/FreeRDP/following{/other_user}","gists_url":"https://api.github.com/users/FreeRDP/gists{/gist_id}","starred_url":"https://api.github.com/users/FreeRDP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FreeRDP/subscriptions","organizations_url":"https://api.github.com/users/FreeRDP/orgs","repos_url":"https://api.github.com/users/FreeRDP/repos","events_url":"https://api.github.com/users/FreeRDP/events{/privacy}","received_events_url":"https://api.github.com/users/FreeRDP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FreeRDP/FreeRDP","description":"FreeRDP is a free remote desktop protocol client","fork":false,"url":"https://api.github.com/repos/FreeRDP/FreeRDP","forks_url":"https://api.github.com/repos/FreeRDP/FreeRDP/forks","keys_url":"https://api.github.com/repos/FreeRDP/FreeRDP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FreeRDP/FreeRDP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FreeRDP/FreeRDP/teams","hooks_url":"https://api.github.com/repos/FreeRDP/FreeRDP/hooks","issue_events_url":"https://api.github.com/repos/FreeRDP/FreeRDP/issues/events{/number}","events_url":"https://api.github.com/repos/FreeRDP/FreeRDP/events","assignees_url":"https://api.github.com/repos/FreeRDP/FreeRDP/assignees{/user}","branches_url":"https://api.github.com/repos/FreeRDP/FreeRDP/branches{/branch}","tags_url":"https://api.github.com/repos/FreeRDP/FreeRDP/tags","blobs_url":"https://api.github.com/repos/FreeRDP/FreeRDP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FreeRDP/FreeRDP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FreeRDP/FreeRDP/git/refs{/sha}","trees_url":"https://api.github.com/repos/FreeRDP/FreeRDP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FreeRDP/FreeRDP/statuses/{sha}","languages_url":"https://api.github.com/repos/FreeRDP/FreeRDP/languages","stargazers_url":"https://api.github.com/repos/FreeRDP/FreeRDP/stargazers","contributors_url":"https://api.github.com/repos/FreeRDP/FreeRDP/contributors","subscribers_url":"https://api.github.com/repos/FreeRDP/FreeRDP/subscribers","subscription_url":"https://api.github.com/repos/FreeRDP/FreeRDP/subscription","commits_url":"https://api.github.com/repos/FreeRDP/FreeRDP/commits{/sha}","git_commits_url":"https://api.github.com/repos/FreeRDP/FreeRDP/git/commits{/sha}","comments_url":"https://api.github.com/repos/FreeRDP/FreeRDP/comments{/number}","issue_comment_url":"https://api.github.com/repos/FreeRDP/FreeRDP/issues/comments{/number}","contents_url":"https://api.github.com/repos/FreeRDP/FreeRDP/contents/{+path}","compare_url":"https://api.github.com/repos/FreeRDP/FreeRDP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FreeRDP/FreeRDP/merges","archive_url":"https://api.github.com/repos/FreeRDP/FreeRDP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FreeRDP/FreeRDP/downloads","issues_url":"https://api.github.com/repos/FreeRDP/FreeRDP/issues{/number}","pulls_url":"https://api.github.com/repos/FreeRDP/FreeRDP/pulls{/number}","milestones_url":"https://api.github.com/repos/FreeRDP/FreeRDP/milestones{/number}","notifications_url":"https://api.github.com/repos/FreeRDP/FreeRDP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FreeRDP/FreeRDP/labels{/name}","releases_url":"https://api.github.com/repos/FreeRDP/FreeRDP/releases{/id}","created_at":"2011-06-30T19:14:15Z","updated_at":"2015-03-19T16:21:57Z","pushed_at":"2015-03-20T10:49:31Z","git_url":"git://github.com/FreeRDP/FreeRDP.git","ssh_url":"git@github.com:FreeRDP/FreeRDP.git","clone_url":"https://github.com/FreeRDP/FreeRDP.git","svn_url":"https://github.com/FreeRDP/FreeRDP","homepage":"http://www.freerdp.com/","size":116954,"stargazers_count":897,"watchers_count":897,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":581,"mirror_url":null,"open_issues_count":535,"forks":581,"open_issues":535,"watchers":897,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FreeRDP/FreeRDP/pulls/2443"},"html":{"href":"https://github.com/FreeRDP/FreeRDP/pull/2443"},"issue":{"href":"https://api.github.com/repos/FreeRDP/FreeRDP/issues/2443"},"comments":{"href":"https://api.github.com/repos/FreeRDP/FreeRDP/issues/2443/comments"},"review_comments":{"href":"https://api.github.com/repos/FreeRDP/FreeRDP/pulls/2443/comments"},"review_comment":{"href":"https://api.github.com/repos/FreeRDP/FreeRDP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FreeRDP/FreeRDP/pulls/2443/commits"},"statuses":{"href":"https://api.github.com/repos/FreeRDP/FreeRDP/statuses/f94935224c49f332c3f69168e1c1a2359f24b310"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":82,"deletions":6,"changed_files":2}}