bug in IdGlobalProtocols

Giganews Newsgroups
Subject: bug in IdGlobalProtocols
Posted by:  loki (loki5100-newsgro…@yahoo.fr)
Date: Fri, 2 Dec 2005

if the procedure procedure FillMimeTable(AMIMEList : TIdStringList);

.....
      Reg.RootKey := HKEY_CLASSES_ROOT;
      if Reg.OpenKeyReadOnly('\') then  {do not localize}
      begin
        Reg.GetKeyNames(KeyList);
      //  reg.Closekey;
      end;
      // get a list of registered extentions
      for i := 0 to KeyList.Count - 1 do
      begin
        if Copy(KeyList[i], 1, 1) = '.' then  {do not localize}
        begin
          if reg.OpenKeyReadOnly(KeyList[i]) then
          begin
            s := Reg.ReadString('Content Type');  {do not localize}
{          if Reg.ValueExists('Content Type') then  {do not localize}
{          begin
            FFileExt.Values[KeyList[i]] := Reg.ReadString('Content Type');
{do not localize}
{          end;  }

{ for some odd reason, the code above was triggering a memory leak inside
the TIdHTTPServer demo program even though simply testing the MIME Table
alone did not cause a memory leak.  That is what I found in my leak
testing..
Got me <shrug>.

}
            if Length(s) > 0 then
            begin
              AMIMEList.Values[KeyList[i]] := s;
            end;
//            reg.CloseKey;
          end;
        end;
      end;
....

The procedure below is false because the loop will only open the FIRST key
!!!
you need to replace
if reg.OpenKeyReadOnly(KeyList[i]) then
by
if reg.OpenKeyReadOnly('\' + KeyList[i]) then

Can you make the modification (and add my name to the contributor :)

Stephane

Replies