PRB: Retrieving Properties with OLE DB May Cause Memory Leak (293349)
The information in this article applies to:
- Microsoft OLE DB 2.0
- Microsoft OLE DB 2.1
- Microsoft OLE DB 2.5
- Microsoft OLE DB 2.6
- Microsoft Data Access Components 2.7
This article was previously published under Q293349 SYMPTOMS
Whenever an OLE DB consumer application retrieves properties from the provider, it is the responsibility of the consumer application to free the memory associated with the property structures that the provider returns.
In some cases, however, freeing the property structures alone, as described in the OLE DB documentation, is not sufficient. Retrieving and freeing the properties will cause a memory leak in this case.
CAUSE
The DBPROPSET structures returned to the client by the provider contain a pointer to an array of DBPROP structures. The DBPROP structures have a VARIANT member called vValue. Because the vValue member could contain a pointer to a BSTR or other allocated memory on output, the vValue member should be cleared by the consumer application by calling the VariantClear function. The OLE DB documentation does not specify this.
RESOLUTION
Call VariantClear on the vValue member of every DBPROP structure in every DBPROP array before freeing the DBPROP array.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 5/12/2003 |
---|
Keywords: | kbConsumer kbDatabase kbprb KB293349 |
---|
|