TIdCookieManager -> A/V

Giganews Newsgroups
Subject: TIdCookieManager -> A/V
Posted by:  Steven Forbes (…@not_an_address.com)
Date: Thu, 29 Jul 2004

Hi group

I'm getting an AccessViolation in the TIdCookieManager.pas unit - dated 26.5.2004. I can reproduce the problem consistently, but not
in any straightforward, easily demonstrable way.

The error is -

EStringListError: List index out of bounds (0)

...and occurs on line 249. I don't know the precise cause, but I speculate that it's because of the nature of the loop in the
CleanupCookieList method. We have

      for j := LCookieList.Count - 1 downto 0 do
        begin

          S := LCookieList.Cookies[j].Expires;
          if (Length(S) > 0) and (GMTToLocalDateTime(S) < Now) then
          begin
            // The Cookie has exiered. It has to be removed from the collection
            LCookieList.Cookies[j].Free;
            LCookieList.Delete(j);  //FLX
          end;

        end;

...I note that the exception occurs after an item has been removed from LCookieList. Since this is a for-loop, the 'j' counter isn't
adjusted to compensate for the removed item - so I think it might be something to do with that: I'll try again and see if I can get
a more accurate impression. I'll also try changing the loop to a 'while', and see whether that makes any difference.

Replies