X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fstring.cc;h=89b33e1180069707c1396c9e2ea9a5f05894f4a6;hb=97de2eaf845eed07e5e6e05d7f2509ca04911de0;hp=1c44e996d680e46e7143463fe51b15aa09e7cf93;hpb=14ed08eb76405aed0747568326058ab57c5e69a2;p=awesomized%2Flibmemcached diff --git a/libmemcached/string.cc b/libmemcached/string.cc index 1c44e996..89b33e11 100644 --- a/libmemcached/string.cc +++ b/libmemcached/string.cc @@ -279,16 +279,21 @@ const char *memcached_string_value(const memcached_string_st& self) char *memcached_string_take_value(memcached_string_st *self) { - assert_msg(self, "Invalid memcached_string_st"); - // If we fail at adding the null, we copy and move on - if (memcached_success(memcached_string_append_null(self))) + char* value= NULL; + + if (memcached_string_length(self)) { - return memcached_string_c_copy(self); - } + assert_msg(self, "Invalid memcached_string_st"); + // If we fail at adding the null, we copy and move on + if (memcached_success(memcached_string_append_null(self))) + { + return memcached_string_c_copy(self); + } - char *value= self->string; + value= self->string; - _init_string(self); + _init_string(self); + } return value; }