More malloc checking

In both cases, fallback to doing nothing if alloc fails.