[server] Fix memory bugs.