in xe_new change casting to be more narrowly tailored; and replace malloc usage which failed to check for NULL with an automatic buffer