Skip to content

Commit

Permalink
Merged PR 3695437: Fix leak of the region GDI handle
Browse files Browse the repository at this point in the history
`CRgnHandle rgn` leaks the region created by the `CreateRectRgnIndirect` method in each OnPaint method call.

This means, that if the download takes a while and we exhaust the GDI object limit, then `CreateRectRgnIndirect` will fail and bootstrapper would crash.

It seems that this code had been there since 2015.

I'd guess it's a bad copy-paste from other places where `CreateRectRgnIndirect`.
Changing `rgn` to be of type `CRgn` ensures that `DeleteObject` is called when the object goes out of scope.

Related work items: #23349119
  • Loading branch information
Maciek Kumorek authored and sorinj committed Sep 3, 2019
1 parent bfc92f1 commit 68f0431
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion omaha/ui/owner_draw_title_bar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ LRESULT CustomProgressBarCtrl::OnPaint(UINT,
ASSERT1(progress_bar_rect.left <= progress_bar_rect.right);
}

CRgnHandle rgn(::CreateRectRgnIndirect(&client_rect));
CRgn rgn(::CreateRectRgnIndirect(&client_rect));
CRgn rgn_temp(::CreateRectRgnIndirect(&progress_bar_rect));
VERIFY1(rgn.CombineRgn(rgn_temp, RGN_DIFF) != RGN_ERROR);

Expand Down

0 comments on commit 68f0431

Please sign in to comment.