Fixed missing return value and added zmalloc