fix zeroing in xmalloc

This commit fixes a potential segfault if malloc failed.