SAFEARRAY* are not freed

Description

Charlie Heap is using Delphi and he reported:

I think I may also have found a small issue in which the Options get locked by calls to GDALUtils and don’t get properly unlocked – even if you destroy the GDAL Utils component. This causes an error message in Delphi apps as follows: “Variant or Safe Array is locked”.

Environment

None

Activity

Show:
Paul Meems
July 12, 2019, 10:17 AM

The suggested changes have been made in commit

Waiting for Charlie to confirm it is also solving his problem in Delphi.

Jerry Faust
July 5, 2019, 5:02 PM

Searching for all occurrences of SafeArrayAccessData, it looks like the following are missing the corresponding SafeArrayUnaccessData:

  1. CGdalUtils::ConvertSafeArray

  2. CTableClass::Join3

  3. CUtils::MergeImages

  4. CUtils::ValidateInputNames

  5. CUtils::ParseSafeArray

 

Paul Meems
June 28, 2019, 10:04 AM
Edited

investigated this and concluded:

The short of it is that each call to SafeArrayAccessData should have a corresponding call to SafeArrayUnaccessData, once we are done iterating/evaluating the contents of the array. There are a number of places in the code in which you'll find the array is left locked, but I would guess that for many of these, the array is only internal, and the circumstances aren't revealing that a lock is left in place.

 

Done

Assignee

Jerry Faust

Reporter

Paul Meems

Labels

None

Fix versions

Affects versions

Priority

Medium