From 6e7d71319c8742425695d9373c8c0bebe2d14544 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 6 Aug 2013 13:44:51 -0400 Subject: [PATCH 1/1] Fix bad if path --- libmemcached/string.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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; -- 2.30.2