From 2591901b9d269681fa622d8fe28d4bf3a9dafaf1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 Feb 2019 15:47:28 +0000 Subject: Fix crash with empty SSA subtitle. --- src/ssa_reader.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ssa_reader.cc b/src/ssa_reader.cc index 471931f..b899da6 100644 --- a/src/ssa_reader.cc +++ b/src/ssa_reader.cc @@ -212,9 +212,11 @@ SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_r /* Count the number of line breaks */ int line_breaks = 0; - for (size_t i = 0; i < line.length() - 1; ++i) { - if (line[i] == '\\' && (line[i+1] == 'n' || line[i+1] == 'N')) { - ++line_breaks; + if (line.length() > 1) { + for (size_t i = 0; i < line.length() - 1; ++i) { + if (line[i] == '\\' && (line[i+1] == 'n' || line[i+1] == 'N')) { + ++line_breaks; + } } } -- cgit v1.2.3