Skip to content

Commit 1c66049

Browse files
src/utils/merge-methcounts.cpp: fixing a bug that was adding extra null char at the start of each line
1 parent d6c88e4 commit 1c66049

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/utils/merge-methcounts.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,13 @@ write_line_for_tabular(std::array<char, buffer_size> &buffer,
208208
cursor += n_bytes;
209209
bytes_left -= n_bytes;
210210
}
211-
if (std::distance(buffer.data(), cursor) + 1 <
212-
static_cast<std::ptrdiff_t>(buffer_size))
213-
*cursor++ = '\n';
214-
215-
if (std::distance(buffer.data(), cursor) <
216-
static_cast<std::ptrdiff_t>(buffer_size)) {
217-
*cursor++ = '\0';
218-
out.write(buffer.data(), std::distance(buffer.data(), cursor));
219-
}
211+
212+
if (static_cast<std::ptrdiff_t>(buffer_size) <=
213+
std::distance(buffer.data(), cursor))
214+
throw std::runtime_error("failed to write output line");
215+
216+
*cursor++ = '\n';
217+
out.write(buffer.data(), std::distance(buffer.data(), cursor));
220218
}
221219

222220
static void

0 commit comments

Comments
 (0)