From 7335c520c1ef0f21d260f8685f9e09af4d5d2738 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 29 Mar 2012 19:05:37 +0000 Subject: [PATCH] Ensure that the text field is terminated when writing EBU STL files The text field must be terminated with 0x8F, so write an extra block if the last block is filled exactly. Originally committed to SVN as r6637. --- aegisub/src/subtitle_format_ebu3264.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aegisub/src/subtitle_format_ebu3264.cpp b/aegisub/src/subtitle_format_ebu3264.cpp index e3034cf27..1dd8c0312 100644 --- a/aegisub/src/subtitle_format_ebu3264.cpp +++ b/aegisub/src/subtitle_format_ebu3264.cpp @@ -546,9 +546,14 @@ namespace tti.push_back(base); // write an extension block number if the remaining text doesn't fit in the block - tti.back().ebn = bytes_remaining > block_size ? num_blocks++ : 255; + tti.back().ebn = bytes_remaining >= block_size ? num_blocks++ : 255; std::copy(&fullstring[pos], &fullstring[pos + std::min(block_size, bytes_remaining)], tti.back().tf); + + // Write another block for the terminator if we exactly used up + // the last block + if (bytes_remaining == block_size) + tti.push_back(base); } }