memcached error (fwd)

Brad Fitzpatrick brad at
Tue Dec 28 11:28:21 PST 2004

For the PHP folk...

---------- Forwarded message ----------
Date: Tue, 28 Dec 2004 13:43:30 +0300
From: Lebedev Pavel <pavel at>
To: brad at
Subject: memcached error

Hello, Brad Fitzpatrick's!

I find error in Release 1.0.10
In case of data end sign ( /r/nEND/r/n ) be at edge of  2 block, the script fall down.
But the following condition must be meeted: last /n is only symbol of last block ($line="\n").
In this case next expression donn`t allow perform end sign checking:

// skip over the extra return or newline
if($line == "\r" || $line == "\n")

$bytes_read += strlen($line);
$buf .= $line;

// we read the all of the data, take in account
// for the /r/nEND/r/n           
if($bytes_read == ($len + 7))
    $end = substr($buf, $len+2, 3);

Example of code, that result fall down:

$options["servers"] = array("");
$options["debug"] = false;
$options["compress"] = 0;
$memc = new MemCachedClient($options);

$str = str_repeat('1', 994);
$memc->set('key', $str);
echo $memc->get('key'); // here script fall


Pavel Lebedev

More information about the memcached mailing list