From dd328df9676cabcf024409ab6d8521c80b4ab99c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 14 Jul 2019 19:40:42 +0100 Subject: Fix crash with unexpected color formats. --- src/subrip_reader.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/subrip_reader.cc') diff --git a/src/subrip_reader.cc b/src/subrip_reader.cc index cf0b86f..cfeeade 100644 --- a/src/subrip_reader.cc +++ b/src/subrip_reader.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2019 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ #include "subrip_reader.h" #include "exceptions.h" #include "util.h" +#include "sub_assert.h" #include #include #include @@ -241,9 +242,12 @@ SubripReader::convert_line (string t, RawSubtitle& p) if (boost::regex_search (tag, match, re) && string (match[1]).size() == 6) { p.colour = Colour::from_rgb_hex (match[1]); colours.push_back (p.colour); + } else { + throw SubripError (tag, "a colour in the format #rrggbb", _context); } } else if (tag == "/font") { maybe_content (p); + SUB_ASSERT (!colours.empty()); colours.pop_back (); p.colour = colours.back (); } -- cgit v1.2.3