bam_merge: get rid of asprintf warnings

Get rid of the asprintf warnings by checking return value and exiting if memory allocation fails.