AlistairNWard/vcfCTools — Issue #1: garbled output, segfault on intersection of two large vcf files
Author: kmsquire
Created: 2011-12-02 20:48:20+00:00
State: open

Hi,

I was having trouble intersecting two large vcf files (garbled output, segfault), and tracked it down to flushToBuffer() erasing objects in a map before incrementing to the next pointer. The patch below fixes this.

Thanks,

Kevin

```diff
diff --git a/output.cpp b/output.cpp
index 44a7c48..c69dbd2 100644
--- a/output.cpp
+++ b/output.cpp
@@ -42,8 +42,8 @@ void output::flushToBuffer(int position, string& referenceSequence) {
for (recordIter = obIter->second.begin(); recordIter != obIter->second.end(); recordIter++) {
*outputStream << *recordIter << endl;
}
- outputBuffer.erase(obIter);
}
+ outputBuffer.erase(outputBuffer.begin(), outputBuffer.end());
}

// If the output buffer contains more than 1000 entries, flush the
@@ -66,6 +66,6 @@ void output::flushOutputBuffer() {
for (recordIter = obIter->second.begin(); recordIter != obIter->second.end(); recordIter++) {
*outputStream << *recordIter << endl;
}
- outputBuffer.erase(obIter);
}
+ outputBuffer.erase(outputBuffer.begin(), outputBuffer.end());
}
```