From 2722df87829006dcc84220d85acf3b45eb6ac197 Mon Sep 17 00:00:00 2001 From: Jonathan Swartz Date: Fri, 22 May 2015 12:19:54 -0700 Subject: [PATCH] Add short-circuit return in Wrong::FailureMessage::wrap_and_indent, to prevent infinite loop in environments where the width of Wrong::Terminal.size is incorrectly set to 0 (or <=6) --- lib/wrong/failure_message.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/wrong/failure_message.rb b/lib/wrong/failure_message.rb index 522cb19..3a9aece 100644 --- a/lib/wrong/failure_message.rb +++ b/lib/wrong/failure_message.rb @@ -188,7 +188,9 @@ def wrap_and_indent(indented, starting_col, indent_wrapped_lines, full_width) while line.length > width s << line[0...width] s << newline(indent_wrapped_lines) + old_length = line.length line = line[width..-1] + return indented unless line.length < old_length if first_line width += starting_col - indent_wrapped_lines first_line = false