Added missing calloc() result checks

Added safety checks around calloc() call, which can fail.