DESC
In the library, do some malloc() checks that were missing, fix a strange but
possible memory leak and also a segmentation fault. 
EDESC

This patch do several malloc() related things in the C library.

First of all, it adds missing malloc() return checks. Then it fixes a memory
leak in get_cmd where we could return without freeing some memory we
allocated, and then (and probably most important of all) fixes a segmentation
fault that could happen if the server crashed when the client was waiting for
a lock.

