general: added some malloc checks