Re: EAV in TIdPOP3.CheckMessages

Giganews Newsgroups
Subject: Re: EAV in TIdPOP3.CheckMessages
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Mon, 6 Dec 2004

"Thomas Zangl" <usen…@tzis.net> wrote in message
news:34156C17F5B6E240usen…@tzis.net...

> Sometimes I get an exception:
<snip>
>      Result := StrToInt(Copy(s, 1, IndyPos(' ', s) - 1)); // <-- HERE
<snip>
> It´s caused by some invalid string "s" converted to an Integer. It seems
> some POP Servers (courier in my case) sometimes send a bad reply to the
> STAT command.

RFC 1939 is *very* specific about the required format of the STAT response.
If the server is sending a malformed response, the the server is buggy and
you should not be using it.  The server's author needs to be told that the
server is not RFC-compliant so that it can be fixed.

Please show the actual response text that the server is returning.

> Solution: Replace StrToInt with "StrToIntDef".

That is not a solution.  That is a hack, and not a very elegant one because
it causes a false return value to be returned.  A better solution would be
to throw an Indy-related exception.  Indy is designed to throw exceptions
when errors occur.  You are preventing that from happening.  It is your own
responsibility to include exception handling in your own code to catch
errors when they occur.

> This fixes the EAV.

What you are seeing happen is not an EAccessViolation, which is only caused
by accessing invalid memory.  What you are seeing instead is an
EConvertError instead.  That is a very different error condition.

Gambit

Replies

In response to

EAV in TIdPOP3.CheckMessages posted by Thomas Zangl on Mon, 06 Dec 2004