From: Brian Aker Date: Tue, 6 Aug 2013 17:44:51 +0000 (-0400) Subject: Fix bad if path X-Git-Tag: 1.0.18~22^2~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=6e7d71319c8742425695d9373c8c0bebe2d14544;p=awesomized%2Flibmemcached Fix bad if path --- diff --git a/libmemcached/string.cc b/libmemcached/string.cc index ce96b98c..b821aca6 100644 --- a/libmemcached/string.cc +++ b/libmemcached/string.cc @@ -281,18 +281,20 @@ char *memcached_string_take_value(memcached_string_st *self) { char* value= NULL; - if (memcached_string_length(self)) + assert_msg(self, "Invalid memcached_string_st"); + if (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))) + if (memcached_string_length(self)) { - return memcached_string_c_copy(self); + // If we fail at adding the null, we copy and move on + if (memcached_failed(memcached_string_append_null(self))) + { + return NULL; + } + + value= self->string; + _init_string(self); } - - value= self->string; - - _init_string(self); } return value;