From 3fd7c8635218cffbf3780810b935cd06d9b1ff1a Mon Sep 17 00:00:00 2001 From: "tommi@chromium.org" Date: Fri, 30 Jul 2010 20:07:48 +0000 Subject: Handle a case if BindContextInfo::FromBindContext fails and not leak a ProtData instance. BUG=none TEST=fixes a potential memory leak. Review URL: http://codereview.chromium.org/2832097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54366 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome_frame/protocol_sink_wrap.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'chrome_frame') diff --git a/chrome_frame/protocol_sink_wrap.cc b/chrome_frame/protocol_sink_wrap.cc index eeefbb9..330e300 100644 --- a/chrome_frame/protocol_sink_wrap.cc +++ b/chrome_frame/protocol_sink_wrap.cc @@ -225,10 +225,14 @@ bool IsCFRequest(IBindCtx* pbc) { } void PutProtData(IBindCtx* pbc, ProtData* data) { + // AddRef and Release to avoid a potential leak of a ProtData instance if + // FromBindContext fails. + data->AddRef(); ScopedComPtr info; BindContextInfo::FromBindContext(pbc, info.Receive()); if (info) info->set_prot_data(data); + data->Release(); } bool IsTextHtml(const wchar_t* status_text) { -- cgit v1.1