bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CVS update: MODIFIED: src ...


From: Derek Robert Price
Subject: Re: CVS update: MODIFIED: src ...
Date: Sat, 26 Jul 2003 22:38:24 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1

Paul Edwards wrote:

Actually, on an empty string, the above code will try to

access str[-1], which could cause a memory violation
(read, not write).

And strlen() actually returns a size_t, ie normally an unsigned int,
so if you do it properly, you would actually go:

strip_trailing_newlines (char *str)
{
   size_t len, origlen;
   len = origlen = strlen (str);

   while (len > 0 && str[--len] == '\n' )
   {
       str[len] = '\0';
   }
   return len != origlen;
}

Yeah, thanks. I fixed that yesterday about 2 o'clock. John pointed it out soon after the commit.

Derek

--
               *8^)

Email: derek@ximbiot.com

Get CVS support at <http://ximbiot.com>!
--
Were it left for me to decide whether we should have a government without 
newspapers, or newspapers without a government, I should not hesitate a moment 
to prefer the latter.
                        - Thomas Jefferson
                        (appeared
http://hotwired.lycos.com/special/lawsuit/ )





reply via email to

[Prev in Thread] Current Thread [Next in Thread]