malloc: replace panics with error messages