- ptr->hosts= (memcached_host_st *)realloc(ptr->hosts, sizeof(memcached_host_st) * (ptr->number_of_hosts+1));
- ptr->hosts[ptr->number_of_hosts].hostname=
+ new_host_list= (memcached_server_st *)realloc(ptr->hosts, sizeof(memcached_server_st) * (ptr->number_of_hosts+1));
+ if (!new_host_list)
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ memset(&new_host_list[ptr->number_of_hosts], 0, sizeof(memcached_server_st));
+
+ if (!new_host_list)
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+
+ ptr->hosts= new_host_list;
+
+ new_hostname=