Skip to content

Commit 0c6125d

Browse files
authored
Fixed bug when 'END' is contained in the cached data
From lusentis pull request elbart#23
1 parent 7a57a9d commit 0c6125d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/memcache.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ Client.prototype.handle_get = function(buffer) {
278278
var end_indicator_len = 3;
279279
var result_len = 0;
280280

281-
if (buffer.indexOf('END') == 0) {
281+
if (buffer.lastIndexOf('END') == 0) {
282282
return [result_value, end_indicator_len + crlf_len];
283-
} else if (buffer.indexOf('VALUE') == 0 && buffer.indexOf('END') != -1) {
283+
} else if (buffer.indexOf('VALUE') == 0 && buffer.lastIndexOf('END') != -1) {
284284
first_line_len = buffer.indexOf(crlf) + crlf_len;
285-
var end_indicator_start = buffer.indexOf('END');
285+
var end_indicator_start = buffer.lastIndexOf('END');
286286
result_len = end_indicator_start - first_line_len - crlf_len;
287287
result_value = buffer.substr(first_line_len, result_len);
288288
return [result_value, first_line_len + parseInt(result_len, 10) + crlf_len + end_indicator_len + crlf_len]

0 commit comments

Comments
 (0)