X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fmemcached_get.c;h=4894b2a05ef32334a9f26029057412ee5ac2dda7;hb=04ba254a9c8b8be2aec1794bece362bc819acffc;hp=c7c21d1ee43ad7518700d1c6f026ca1323dcd62a;hpb=b9298b65419d873299e010afa0f4eca2c8259969;p=m6w6%2Flibmemcached diff --git a/lib/memcached_get.c b/lib/memcached_get.c index c7c21d1e..4894b2a0 100644 --- a/lib/memcached_get.c +++ b/lib/memcached_get.c @@ -96,6 +96,13 @@ static char *memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_len value_ptr= value; read_length= 0; + /* + We read the \r\n into the string since not doing so is more + cycles then the waster of memory to do so. + + We are null terminating through, which will most likely make + some people lazy about using the return length. + */ to_read= (*value_length) + 2; read_length= memcached_io_read(ptr, server_key, @@ -107,6 +114,9 @@ static char *memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_len goto read_error; } + value[*value_length]= 0; + value[(*value_length) + 1]= 0; + return value; } }