[pywin32-bugs] [ pywin32-Bugs-1203980 ] Universal Gateway mishandles ByRef Variant arguments
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2005-06-27 11:03:06
|
Bugs item #1203980, was opened at 2005-05-18 09:39 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1203980&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: George van den Driessche (gbmvdd) Assigned to: Nobody/Anonymous (nobody) Summary: Universal Gateway mishandles ByRef Variant arguments Initial Comment: Symptoms ======== PyWin32 is installed from pywin32-204.win32-py2.3.exe. Using win32com.server to add commands to Visual Studio .NET 2003, dispatch to IDTCommandTarget.QueryStatus fails, saying "Cant convert vectors!". Execution never reaches the Python COM server's implementation of the QueryStatus method. Cause ===== in univgw_dataconv.cpp, in dataconv_ReadFromInTuple (), there is a bug in the handling of ByRef Variant arguments. Such an argument is not dereferenced before being passed to PyCom_PyObjectFromVariant(), so that the code attempts to construct a Python object from data that does not constitute a Variant. In the worst case this could cause an access violation and the premature death of the host process. Solution ======== Applying the following patch to univgw_dataconv.cpp solves the problem, allowing Python commands to be added to Visual Studio: -------- diff -------- 711,713c711,720 < // A pointer to a _real_ variant. < VARIANT *pVar = (VARIANT *)pb; < obArg = PyCom_PyObjectFromVariant(pVar); --- > > // A _real_ variant. > if (bIsByRef) > { > obArg = PyCom_PyObjectFromVariant(* (VARIANT**)pb); > } > else > { > obArg = PyCom_PyObjectFromVariant ((VARIANT*)pb); > } -------- diff -------- I have tested the above diff using a debug build of pywin32 running on Python 2.4.1. Remarks ======= The above diff brings the code for handling ByRef Variants into line with the nearby code for handling ByRef Int64s, and also with the corresponding code for handling ByRef Variants in dataconv_WriteFromOutTuple (). ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2005-06-27 21:03 Message: Logged In: YES user_id=14198 checked into CVS - thanks. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1203980&group_id=78018 |