Fix crash on make-dcp after trimming end of text subtitles (#1275).
authorCarl Hetherington <cth@carlh.net>
Thu, 19 Apr 2018 21:51:45 +0000 (22:51 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 14 May 2018 22:21:25 +0000 (23:21 +0100)
(cherry-picking cd810b7658b0f4910c093ac191c2b4ba06ba0677 from master)

ChangeLog
src/lib/player.cc

index b79e07801846374647ff19a59b931cf9d74ab0a1..035dee09efd685bf2673d59b3a3ab4386b733c25 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
        * Fix invalid timings in SMPTE subtitle files (causing failure to play subtitles)
        in some cases (#1293).
 
+2018-04-19  Carl Hetherington  <cth@carlh.net>
+
+       * Fix crash on making a DCP after trimming the end of some text-based subtitles (#1275).
+
 2018-04-14  Carl Hetherington  <cth@carlh.net>
 
        * Version 2.12.4 released.
index 148e0a3c5842bc2115cf0790179167a29924d4c7..7e0186bf42e71cf307f6a2548f5add40ddc06c63 100644 (file)
@@ -888,6 +888,10 @@ Player::text_subtitle_start (weak_ptr<Piece> wp, ContentTextSubtitle subtitle)
        PlayerSubtitles ps;
        DCPTime const from (content_time_to_dcp (piece, subtitle.from()));
 
+       if (from > piece->content->end()) {
+               return;
+       }
+
        BOOST_FOREACH (dcp::SubtitleString s, subtitle.subs) {
                s.set_h_position (s.h_position() + piece->content->subtitle->x_offset ());
                s.set_v_position (s.v_position() + piece->content->subtitle->y_offset ());
@@ -930,6 +934,10 @@ Player::subtitle_stop (weak_ptr<Piece> wp, ContentTime to)
 
        DCPTime const dcp_to = content_time_to_dcp (piece, to);
 
+       if (dcp_to > piece->content->end()) {
+               return;
+       }
+
        pair<PlayerSubtitles, DCPTime> from = _active_subtitles.add_to (wp, dcp_to);
 
        if (piece->content->subtitle->use() && !_always_burn_subtitles && !piece->content->subtitle->burn()) {