Check mallocs, propagate error to caller.