Skip to content

Commit 2198286

Browse files
mbstadlercsoneson
andcommitted
use bamdata2 when cleaning up curr_records to not lose access to bamdata memory
Co-authored-by: Charlotte Soneson <charlottesoneson@gmail.com> Co-authored-by: Michael Stadler <stadler.michael@gmail.com>
1 parent a9c81be commit 2198286

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/read_mismatchbam_cpp.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -710,12 +710,12 @@ Rcpp::List read_mismatchbam_cpp(std::string inname_str,
710710
for (curr_records_it = curr_records.begin();
711711
curr_records_it != curr_records.end();
712712
curr_records_it++) {
713-
bamdata = curr_records_it->second;
713+
bamdata2 = curr_records_it->second;
714714

715715
if ((n_alns_to_sample == 0) || (R::runif(0, 1) < keep_aln_fraction)) {
716716
success = process_mismatch_bam_record(
717717
MISMATCHBAM_MODE_STATE, // run mode
718-
bamdata, // bam record
718+
bamdata2, // bam record
719719
bam_format, // format of bam file
720720
alncnt, // alignment counter
721721
had_error, // error flag
@@ -750,9 +750,9 @@ Rcpp::List read_mismatchbam_cpp(std::string inname_str,
750750
}
751751

752752
// remove now processed record from map
753-
if (bamdata) {
754-
bam_destroy1(bamdata);
755-
bamdata = NULL;
753+
if (bamdata2) {
754+
bam_destroy1(bamdata2);
755+
bamdata2 = NULL;
756756
}
757757

758758
if (verbose && CLI_SHOULD_TICK) { // # nocov start

0 commit comments

Comments
 (0)