Access Violation while TOraSQL freeing
Posted: Tue 14 Jan 2014 15:24
Hello,
I have next problem with ODAC 9.2.5. The problem is with code which looks like that:
When I try to free FOraSQL instance then Access Violation is raised. I think the problem is with TOraNumber class. The exception is raised in TOraNumber destructor:
When Session property for TOraSQL instance is changed then FEnvironment field is set to nil. But in TOraSQL's destructor value of FEnvironment field is not checked. And in this case the exception while freeing is raised. I think the source of problem is in TOraNumber.SetEnvironment procedure:
I think it should be similar to the procedure TOraInterval.SetEnvironment and looks like:
After this correction my code works without exceptions. 
I have next problem with ODAC 9.2.5. The problem is with code which looks like that:
Code: Select all
OraSession1.Connect;
FOraSQL := TOraSQL.Create(Self);
FOraSQL.SQL.Text := 'select * from v$session where sid = :sid';
FOraSQL.Params[0].DataType := TFieldType(107); // Number
FOraSQL.Prepare;
FOraSQL.Session := OraSession2;
FOraSQL.Free; // <--- Access Violation here
Code: Select all
destructor TOraNumber.Destroy;
begin
Marshal.FreeHGlobal(FIndicator);
if FHandleType <> htShared then //To support SetOCINumberPtr assignation
Marshal.FreeHGlobal(phOCINumber);
if FHandleType <> htLocal then begin
{$IFNDEF AUTOREFCOUNT}
FEnvironment.ReleaseRef; // <-- Exactly here is raised exception
Code: Select all
if FEnvironment <> AEnvironment then begin
{$IFNDEF AUTOREFCOUNT}
if FEnvironment <> nil then
FEnvironment.ReleaseRef;
{$ENDIF}
FEnvironment := AEnvironment;
{$IFNDEF AUTOREFCOUNT}
if FEnvironment <> nil then
FEnvironment.AddRef;
{$ENDIF}
end;
Code: Select all
if FEnvironment <> AEnvironment then begin
{$IFNDEF AUTOREFCOUNT}
if FEnvironment <> nil then
FEnvironment.ReleaseRef;
{$ENDIF}
FEnvironment := AEnvironment;
if FEnvironment <> nil then
begin
FHandleType := htNative;
{$IFNDEF AUTOREFCOUNT}
FEnvironment.AddRef;
{$ENDIF}
end
else
FHandleType := htLocal;
end;