From: Derek <derekwbarnett@gmail.com> Date: Mon, 7 Jun 2010 20:18:10 +0000 (-0400) Subject: This fixes the out-of-range exception. Though there's still a discrepancy with some... X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=73433cf4992127c558e72cf75147a9e599330d3f;p=bamtools.git This fixes the out-of-range exception. Though there's still a discrepancy with some (but, maddeningly, not all) tags following a string tag. Will look into to more detail, but at least it shouldn't crash in the meantime --- diff --git a/bamtools_convert.cpp b/bamtools_convert.cpp index de86599..e881d43 100644 --- a/bamtools_convert.cpp +++ b/bamtools_convert.cpp @@ -288,6 +288,8 @@ void BamTools::PrintJSON(ostream& out, const BamAlignment& a) { ++index; break; } + + if ( tagData[index] == '\0') break; } out << "}"; @@ -348,9 +350,7 @@ void BamTools::PrintSAM(ostream& out, const BamAlignment& a) { size_t index = 0; while ( index < tagDataLength ) { - cerr << tagDataLength << " " << index << endl; - - // write tag name + // write tag name out << "\t" << a.TagData.substr(index, 2) << ":"; index += 2; @@ -414,8 +414,9 @@ void BamTools::PrintSAM(ostream& out, const BamAlignment& a) { ++index; break; } + + if ( tagData[index] == '\0') break; } out << endl; - }