[Tizen] partial bug fix from upstream
authorHyungju Lee <leee.lee@samsung.com>
Tue, 13 Sep 2022 01:32:21 +0000 (10:32 +0900)
committer이형주/Common Platform Lab(SR)/삼성전자 <leee.lee@samsung.com>
Tue, 13 Sep 2022 21:14:40 +0000 (06:14 +0900)
Original fix: https://github.com/dotnet/diagnostics/pull/3354

Partially taken: Fix issue #3187. dotnet-dump analyze causes an Exception when console width is 0.
https://github.com/dotnet/diagnostics/pull/3354/files#diff-46973b9bfe85c1f21862c183213d13a8bcb643c81ec69bfc731aa4d1e4924f15

src/Microsoft.Diagnostics.Repl/Console/ConsoleProvider.cs

index 85e64dd6289899bd036b03755a756014d7b26541..c65d400b7102b83904f73557817a0577fc3089b9 100644 (file)
@@ -266,8 +266,10 @@ namespace Microsoft.Diagnostics.Repl
                 return;
             }
 
-            if (m_clearLine == null || m_clearLine.Length != Console.WindowWidth) {
-                m_clearLine = "\r" + new string(' ', Console.WindowWidth - 1);
+            // https://github.com/dotnet/diagnostics/pull/3354/files#diff-46973b9bfe85c1f21862c183213d13a8bcb643c81ec69bfc731aa4d1e4924f15
+            int width = Console.WindowWidth;
+            if (m_clearLine == null || width != m_clearLine.Length) {
+                m_clearLine = "\r" + (width > 0 ? new string(' ', width - 1) : "");
             }
 
             Console.Write(m_clearLine);