Fix a memory leak spotted by Blaise Thorn

pdecsub.pas, parse_proc_head.consume_generic_type_parameter:
  * avoid a memory leak if there are no generic type parameters following

git-svn-id: trunk@23543 -
This commit is contained in:
svenbarth 2013-01-30 15:29:29 +00:00
parent 9315eba917
commit cca897cfd3

View File

@ -656,39 +656,34 @@ implementation
genname : tidstring; genname : tidstring;
s : shortstring; s : shortstring;
begin begin
result:=not assigned(astruct)and(m_delphi in current_settings.modeswitches); result:=not assigned(astruct)and
(m_delphi in current_settings.modeswitches)and
(token in [_LT,_LSHARPBRACKET]);
if result then if result then
begin begin
consume(token);
{ parse all parameters first so we can check whether we have { parse all parameters first so we can check whether we have
the correct generic def available } the correct generic def available }
genparalistdecl:=TFPHashList.Create; genparalistdecl:=TFPHashList.Create;
if try_to_consume(_LT) then
begin { start with 1, so Find can return Nil (= 0) }
{ start with 1, so Find can return Nil (= 0) } idx:=1;
idx:=1; repeat
repeat if token=_ID then
if token=_ID then begin
begin genparalistdecl.Add(pattern, Pointer(PtrInt(idx)));
genparalistdecl.Add(pattern, Pointer(PtrInt(idx))); consume(_ID);
consume(_ID); inc(idx);
inc(idx); end
end else
else begin
begin message2(scan_f_syn_expected,arraytokeninfo[_ID].str,arraytokeninfo[token].str);
message2(scan_f_syn_expected,arraytokeninfo[_ID].str,arraytokeninfo[token].str); if token<>_COMMA then
if token<>_COMMA then consume(token);
consume(token); end;
end; until not try_to_consume(_COMMA);
until not try_to_consume(_COMMA); if not try_to_consume(_GT) then
if not try_to_consume(_GT) then consume(_RSHARPBRACKET);
consume(_RSHARPBRACKET);
end
else
begin
{ no generic }
srsym:=nil;
exit;
end;
s:=''; s:='';
str(genparalistdecl.count,s); str(genparalistdecl.count,s);
@ -706,7 +701,9 @@ implementation
srsym:=nil; srsym:=nil;
exit; exit;
end end
end; end
else
srsym:=nil;
end; end;
procedure consume_generic_interface; procedure consume_generic_interface;