From: Brian Aker Date: Tue, 18 Dec 2007 17:19:09 +0000 (-0800) Subject: Fixed error in lack of pointer found (Tim Bunce discovered) X-Git-Tag: 0.13~19 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3108ba67a2cb6230cb43d24608187f7201951822;p=m6w6%2Flibmemcached Fixed error in lack of pointer found (Tim Bunce discovered) --- diff --git a/ChangeLog b/ChangeLog index ee8246d2..094b807d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ * Patches from Kevin Dalley for FreeBSD 4.0 * Added multi delete functions. * All get key returns have C style null termination + * If memcached_server_list_append is passed NULLs instead of pointers it + returns NULL. 0.12 Tue Dec 11 15:20:55 PST 2007 * Updates for consistent hashing diff --git a/lib/memcached_hosts.c b/lib/memcached_hosts.c index 5661e541..6f49b270 100644 --- a/lib/memcached_hosts.c +++ b/lib/memcached_hosts.c @@ -148,8 +148,8 @@ memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, unsigned int count; memcached_server_st *new_host_list; - if (!hostname) - return ptr; + if (hostname == NULL || error == NULL) + return NULL; if (!port) port= MEMCACHED_DEFAULT_PORT; diff --git a/tests/function.c b/tests/function.c index ae2ec032..5b598003 100644 --- a/tests/function.c +++ b/tests/function.c @@ -40,6 +40,23 @@ uint8_t init_test(memcached_st *not_used) return 0; } +uint8_t server_list_null_test(memcached_st *ptr) +{ + memcached_server_st *server_list; + memcached_return rc; + + server_list= memcached_server_list_append(NULL, NULL, 0, NULL); + assert(server_list == NULL); + + server_list= memcached_server_list_append(NULL, "localhost", 0, NULL); + assert(server_list == NULL); + + server_list= memcached_server_list_append(NULL, NULL, 0, &rc); + assert(server_list == NULL); + + return 0; +} + uint8_t allocation_test(memcached_st *not_used) { memcached_st *memc; @@ -1944,6 +1961,7 @@ test_st tests[] ={ {"flush", 0, flush_test }, {"init", 0, init_test }, {"allocation", 0, allocation_test }, + {"server_list_null_test", 0, server_list_null_test}, {"clone_test", 0, clone_test }, {"error", 0, error_test }, {"set", 0, set_test },