diff --git a/Pythonwin/win32view.cpp b/Pythonwin/win32view.cpp index 5f17fa3778..d08ac0f9d1 100644 --- a/Pythonwin/win32view.cpp +++ b/Pythonwin/win32view.cpp @@ -839,8 +839,8 @@ static PyObject *ui_edit_window_save_file(PyObject *self, PyObject *args) CDocument *pDocument = pView->GetDocument(); if (pDocument) pDocument->SetModifiedFlag(FALSE); // start off with unmodified - PyWinObject_FreeTCHAR(fileName); GUI_END_SAVE; + PyWinObject_FreeTCHAR(fileName); RETURN_NONE; } // @pymethod tuple|PyCEditView|PreCreateWindow|Calls the underlying MFC PreCreateWindow method. diff --git a/Pythonwin/win32win.cpp b/Pythonwin/win32win.cpp index 4d8f9996ed..e069c6ed38 100644 --- a/Pythonwin/win32win.cpp +++ b/Pythonwin/win32win.cpp @@ -1654,9 +1654,9 @@ static PyObject *ui_window_message_box(PyObject *self, PyObject *args) // @pyseemfc CWnd|MessageBox rc = pWnd->MessageBox(message, title, style); + GUI_END_SAVE; PyWinObject_FreeTCHAR(message); PyWinObject_FreeTCHAR(title); - GUI_END_SAVE; return Py_BuildValue("i", rc); // @rdesc An integer identifying the button pressed to dismiss the dialog. } diff --git a/com/win32com/src/extensions/PyIType.cpp b/com/win32com/src/extensions/PyIType.cpp index e45e549250..b2ef392548 100644 --- a/com/win32com/src/extensions/PyIType.cpp +++ b/com/win32com/src/extensions/PyIType.cpp @@ -688,8 +688,8 @@ PyObject *pythoncom_loadtypelib(PyObject *self, PyObject *args) ITypeLib *ptl; PY_INTERFACE_PRECALL; SCODE sc = LoadTypeLib(bstrName, &ptl); - PyWinObject_FreeBstr(bstrName); PY_INTERFACE_POSTCALL; + PyWinObject_FreeBstr(bstrName); if (FAILED(sc)) return PyCom_BuildPyException(sc); diff --git a/com/win32comext/bits/src/PyIBackgroundCopyJob.cpp b/com/win32comext/bits/src/PyIBackgroundCopyJob.cpp index eed6f99fcd..09245a62b4 100755 --- a/com/win32comext/bits/src/PyIBackgroundCopyJob.cpp +++ b/com/win32comext/bits/src/PyIBackgroundCopyJob.cpp @@ -620,9 +620,9 @@ PyObject *PyIBackgroundCopyJob::SetProxySettings(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetProxySettings(ProxyUsage, ProxyList, ProxyBypassList); + PY_INTERFACE_POSTCALL; PyWinObject_FreeWCHAR(ProxyList); PyWinObject_FreeWCHAR(ProxyBypassList); - PY_INTERFACE_POSTCALL; if (FAILED(hr)) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob); Py_INCREF(Py_None); diff --git a/com/win32comext/internet/src/PyIDocHostUIHandler.cpp b/com/win32comext/internet/src/PyIDocHostUIHandler.cpp index 5373a0f5ee..811dcc8c76 100644 --- a/com/win32comext/internet/src/PyIDocHostUIHandler.cpp +++ b/com/win32comext/internet/src/PyIDocHostUIHandler.cpp @@ -376,8 +376,8 @@ PyObject *PyIDocHostUIHandler::TranslateUrl(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDHUIH->TranslateUrl(dwTranslate, pchURLIn, &pchURLOut); - PyWinObject_FreeWCHAR(pchURLIn); PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pchURLIn); if (FAILED(hr)) return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler); PyObject *pyretval = MakeOLECHARToObj(pchURLOut); diff --git a/com/win32comext/internet/src/PyIInternetSecurityManager.cpp b/com/win32comext/internet/src/PyIInternetSecurityManager.cpp index 7063aa14c3..f65748f170 100644 --- a/com/win32comext/internet/src/PyIInternetSecurityManager.cpp +++ b/com/win32comext/internet/src/PyIInternetSecurityManager.cpp @@ -145,8 +145,8 @@ PyObject *PyIInternetSecurityManager::ProcessUrlAction(PyObject *self, PyObject PY_INTERFACE_PRECALL; hr = pIISM->ProcessUrlAction(pwszUrl, dwAction, (BYTE *)&dwPolicy, sizeof(dwPolicy), (BYTE *)context, cbcontext, dwFlags, 0); - PyWinObject_FreeWCHAR(pwszUrl); PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pwszUrl); if (FAILED(hr)) return PyCom_BuildPyException(hr, pIISM, IID_IInternetSecurityManager); return Py_BuildValue("ll", hr, dwPolicy); diff --git a/com/win32comext/shell/src/PyICopyHook.cpp b/com/win32comext/shell/src/PyICopyHook.cpp index b7f4a9802f..e8ec4e11b4 100644 --- a/com/win32comext/shell/src/PyICopyHook.cpp +++ b/com/win32comext/shell/src/PyICopyHook.cpp @@ -54,11 +54,10 @@ PyObject *PyICopyHookA::CopyCallback(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pICH->CopyCallback(hwnd, wFunc, wFlags, srcFile, srcAttribs, destFile, destAttribs); + PY_INTERFACE_POSTCALL; PyWinObject_FreeChars(srcFile); PyWinObject_FreeChars(destFile); - PY_INTERFACE_POSTCALL; - if (FAILED(hr)) return PyCom_BuildPyException(hr, pICH, IID_IShellCopyHook); Py_INCREF(Py_None); @@ -143,10 +142,10 @@ PyObject *PyICopyHookW::CopyCallback(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pICH->CopyCallback(hwnd, wFunc, wFlags, srcFile, srcAttribs, destFile, destAttribs); - PyWinObject_FreeWCHAR(srcFile); - PyWinObject_FreeWCHAR(destFile); PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(srcFile); + PyWinObject_FreeWCHAR(destFile); if (FAILED(hr)) return PyCom_BuildPyException(hr, pICH, IID_IShellCopyHook); diff --git a/com/win32comext/shell/src/PyIExtractIcon.cpp b/com/win32comext/shell/src/PyIExtractIcon.cpp index b1a2a2abef..c0260f0640 100644 --- a/com/win32comext/shell/src/PyIExtractIcon.cpp +++ b/com/win32comext/shell/src/PyIExtractIcon.cpp @@ -38,8 +38,9 @@ PyObject *PyIExtractIcon::Extract(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pIEI->Extract(pszFile, nIconIndex, &hiconLarge, &hiconSmall, nIconSize); - PyWinObject_FreeChars(pszFile); PY_INTERFACE_POSTCALL; + PyWinObject_FreeChars(pszFile); + if (FAILED(hr)) return PyCom_BuildPyException(hr, pIEI, IID_IExtractIcon); if (hr == S_FALSE) diff --git a/com/win32comext/shell/src/PyIExtractIconW.cpp b/com/win32comext/shell/src/PyIExtractIconW.cpp index 23ad4db849..6785de3e90 100644 --- a/com/win32comext/shell/src/PyIExtractIconW.cpp +++ b/com/win32comext/shell/src/PyIExtractIconW.cpp @@ -42,8 +42,9 @@ PyObject *PyIExtractIconW::Extract(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pIEI->Extract(pszFile, nIconIndex, &hiconLarge, &hiconSmall, nIconSize); - PyWinObject_FreeWCHAR(pszFile); PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pszFile); + if (FAILED(hr)) return PyCom_BuildPyException(hr, pIEI, IID_IExtractIconW); if (hr == S_FALSE) diff --git a/com/win32comext/shell/src/PyIQueryAssociations.cpp b/com/win32comext/shell/src/PyIQueryAssociations.cpp index bac7957306..66f963172f 100644 --- a/com/win32comext/shell/src/PyIQueryAssociations.cpp +++ b/com/win32comext/shell/src/PyIQueryAssociations.cpp @@ -45,8 +45,9 @@ PyObject *PyIQueryAssociations::Init(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pIQA->Init(flags, pszAssoc, hkProgid, hwnd); - PyWinObject_FreeWCHAR(pszAssoc); PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pszAssoc); + if (FAILED(hr)) return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations); Py_INCREF(Py_None); @@ -77,8 +78,8 @@ PyObject *PyIQueryAssociations::GetKey(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pIQA->GetKey(flags, (ASSOCKEY)assoc, pszExtra, &ret); - PyWinObject_FreeWCHAR(pszExtra); PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pszExtra); if (FAILED(hr)) return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations); // observation of the "open handles" count in task-manager indicates @@ -116,8 +117,8 @@ PyObject *PyIQueryAssociations::GetString(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pIQA->GetString(flags, (ASSOCSTR)assoc, pszExtra, result_buf, &result_size); - PyWinObject_FreeWCHAR(pszExtra); PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pszExtra); if (FAILED(hr)) return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations); // docs don't explicitly say if result_size includes NULL. It says: diff --git a/com/win32comext/shell/src/PyIShellIconOverlayIdentifier.cpp b/com/win32comext/shell/src/PyIShellIconOverlayIdentifier.cpp index 5e465f8f3d..7541540496 100644 --- a/com/win32comext/shell/src/PyIShellIconOverlayIdentifier.cpp +++ b/com/win32comext/shell/src/PyIShellIconOverlayIdentifier.cpp @@ -43,9 +43,9 @@ PyObject *PyIShellIconOverlayIdentifier::IsMemberOf(PyObject *self, PyObject *ar HRESULT hr; PY_INTERFACE_PRECALL; hr = pISIOI->IsMemberOf(path, attrib); - PyWinObject_FreeWCHAR(path); PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(path); if (FAILED(hr)) return PyCom_BuildPyException(hr, pISIOI, IID_IShellIconOverlayIdentifier); diff --git a/com/win32comext/shell/src/shell.cpp b/com/win32comext/shell/src/shell.cpp index 6afd48d0f2..f7fc2fd5a8 100644 --- a/com/win32comext/shell/src/shell.cpp +++ b/com/win32comext/shell/src/shell.cpp @@ -855,11 +855,11 @@ void PyObject_CleanupDEFCONTEXTMENU(DEFCONTEXTMENU *dcm) dcm->psf->Release(); if (dcm->punkAssociationInfo) dcm->punkAssociationInfo->Release(); + PY_INTERFACE_POSTCALL; if (dcm->pidlFolder) PyObject_FreePIDL(dcm->pidlFolder); if (dcm->apidl) PyObject_FreePIDLArray(dcm->cidl, dcm->apidl); - PY_INTERFACE_POSTCALL; } // @object DEFCONTENTMENU|A tuple representing a DEFCONTEXTMENU structure. diff --git a/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp b/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp index 84baabeab9..5cf9100f7c 100644 --- a/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp +++ b/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp @@ -389,9 +389,8 @@ PyObject *PyIScheduledWorkItem::SetComment(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pISWI->SetComment(pwszComment); - PyWinObject_FreeWCHAR(pwszComment); - PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pwszComment); if (FAILED(hr)) return PyCom_BuildPyException(hr, pISWI, IID_IScheduledWorkItem); @@ -437,9 +436,8 @@ PyObject *PyIScheduledWorkItem::SetCreator(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pISWI->SetCreator(pwszCreator); - PyWinObject_FreeWCHAR(pwszCreator); - PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pwszCreator); if (FAILED(hr)) return PyCom_BuildPyException(hr, pISWI, IID_IScheduledWorkItem); @@ -685,9 +683,9 @@ PyObject *PyIScheduledWorkItem::SetAccountInformation(PyObject *self, PyObject * HRESULT hr; PY_INTERFACE_PRECALL; hr = pISWI->SetAccountInformation(AccountName, Password); + PY_INTERFACE_POSTCALL; PyWinObject_FreeWCHAR(AccountName); PyWinObject_FreeWCHAR(Password); - PY_INTERFACE_POSTCALL; if (FAILED(hr)) return PyCom_BuildPyException(hr, pISWI, IID_IScheduledWorkItem); diff --git a/com/win32comext/taskscheduler/src/PyITask.cpp b/com/win32comext/taskscheduler/src/PyITask.cpp index dd9f8a73f6..c9e3cfaa65 100644 --- a/com/win32comext/taskscheduler/src/PyITask.cpp +++ b/com/win32comext/taskscheduler/src/PyITask.cpp @@ -30,9 +30,8 @@ PyObject *PyITask::SetApplicationName(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pIT->SetApplicationName(pwszApplicationName); - PyWinObject_FreeWCHAR(pwszApplicationName); - PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pwszApplicationName); if (FAILED(hr)) return PyCom_BuildPyException(hr, pIT, IID_ITask); @@ -80,9 +79,8 @@ PyObject *PyITask::SetParameters(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pIT->SetParameters(pwszParameters); - PyWinObject_FreeWCHAR(pwszParameters); - PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(pwszParameters); if (FAILED(hr)) return PyCom_BuildPyException(hr, pIT, IID_ITask); diff --git a/com/win32comext/taskscheduler/src/PyITaskScheduler.cpp b/com/win32comext/taskscheduler/src/PyITaskScheduler.cpp index 4db97abb33..df5953ce57 100644 --- a/com/win32comext/taskscheduler/src/PyITaskScheduler.cpp +++ b/com/win32comext/taskscheduler/src/PyITaskScheduler.cpp @@ -34,8 +34,8 @@ PyObject *PyITaskScheduler::SetTargetComputer(PyObject *self, PyObject *args) HRESULT hr; PY_INTERFACE_PRECALL; hr = pITS->SetTargetComputer(Computer); - PyWinObject_FreeWCHAR(Computer); PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(Computer); if (FAILED(hr)) return PyCom_BuildPyException(hr, pITS, IID_ITaskScheduler);