* xmlread.pp, added a flag to force input stack unwinding upon reader destruction.

Without this, certain (malformed) documents (e.g. eduni/xml-1.1/005.xml) were causing
  InputSource leaks.

  Note: these leaks are a side effect from recent changes to entity processing and are not
  observed with older versions.

git-svn-id: trunk@14361 -
This commit is contained in:
sergei 2009-12-08 08:10:35 +00:00
parent a7d1856620
commit c8efa67ac7

View File

@ -367,7 +367,7 @@ type
procedure SkipQuote(out Delim: WideChar; required: Boolean = True);
procedure Initialize(ASource: TXMLCharSource);
function ContextPush(AEntity: TDOMEntityEx): Boolean;
function ContextPop: Boolean;
function ContextPop(Forced: Boolean = False): Boolean;
procedure XML11_BuildTables;
procedure ParseQuantity(CP: TContentParticle);
procedure StoreLocation(out Loc: TLocation);
@ -1474,7 +1474,7 @@ begin
FreeMem(FName.Buffer);
FreeMem(FValue.Buffer);
if Assigned(FSource) then
while ContextPop do; // clean input stack
while ContextPop(True) do; // clean input stack
FSource.Free;
FPEMap.Free;
ClearRefs(FNotationRefs);
@ -1796,12 +1796,12 @@ begin
Result := True;
end;
function TXMLReader.ContextPop: Boolean;
function TXMLReader.ContextPop(Forced: Boolean): Boolean;
var
Src: TXMLCharSource;
Error: Boolean;
begin
Result := Assigned(FSource.FParent) and (FSource.DTDSubsetType = dsNone);
Result := Assigned(FSource.FParent) and (Forced or (FSource.DTDSubsetType = dsNone));
if Result then
begin
Src := FSource.FParent;
@ -1876,8 +1876,7 @@ begin
FreeMem(FValue.Buffer);
FValue := SaveValue;
Result.SetReadOnly(True);
FSource.DTDSubsetType := dsNone;
ContextPop;
ContextPop(True);
FCursor := SaveCursor;
FState := SaveState;
FValidator[FNesting].FElementDef := SaveElDef;
@ -2298,8 +2297,7 @@ begin
Src.DTDSubsetType := dsExternal;
ParseMarkupDecl;
finally
Src.DTDSubsetType := dsNone;
ContextPop;
ContextPop(True);
end;
end
else