Segfault fix in sam_header2key_val

Ensure that both the key and value are defined in sam_header2key_val