<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/22701388/67914239-7d8f0000-fbca-11e9-931d-8bda1ffeffe5.png"><img src="https://user-images.githubusercontent.com/22701388/67914239-7d8f0000-fbca-11e9-931d-8bda1ffeffe5.png" alt="" style="max-width: 100%;"></a></p>
<h1 dir="auto">Environment</h1>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Windows build number: [run &quot;ver&quot; at a command prompt]
- 10.0.18362.116
- 10.0.18362.267

Windows Terminal version (if applicable):
- No

Any other software?
- No"><pre lang="none" class="notranslate"><code class="notranslate">Windows build number: [run "ver" at a command prompt]
- 10.0.18362.116
- 10.0.18362.267

Windows Terminal version (if applicable):
- No

Any other software?
- No
</code></pre></div>
<h1 dir="auto">Steps to reproduce</h1>

<ul dir="auto">
<li>Unpack the attached project: <a href="https://github.com/microsoft/terminal/files/3483795/BufferSizeBug.zip">BufferSizeBug.zip</a></li>
<li>Open in Visual Studio</li>
<li>Compile &amp; Run</li>
<li>After a MessageBox appears: open window properties, go to Layout tab, <strong>uncheck "Wrap text output on resize"</strong>, close the properties window.</li>
<li>Press OK in the MessageBox</li>
</ul>
<h1 dir="auto">Expected behavior</h1>

<p dir="auto">Conhost doesn't crash.</p>
<h1 dir="auto">Actual behavior</h1>

<p dir="auto">Conhost crashes silently.</p>
<p dir="auto">If you attach the VS debugger to conhost.exe before triggering a crash, it will show something like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="onecore\windows\core\console\open\src\buffer\out\textbuffercelliterator.cpp(49)\conhost.exe!00007FF6AD97FB34: (caller: 00007FF6AD95CACE) Exception(1) tid(22a0) 80070057 The parameter is incorrect.

Exception thrown at 0x00007FFFE34EA839 in conhost.exe: Microsoft C++ exception: wil::ResultException at memory location 0x000000EE660FDFB0."><pre class="notranslate"><code class="notranslate">onecore\windows\core\console\open\src\buffer\out\textbuffercelliterator.cpp(49)\conhost.exe!00007FF6AD97FB34: (caller: 00007FF6AD95CACE) Exception(1) tid(22a0) 80070057 The parameter is incorrect.

Exception thrown at 0x00007FFFE34EA839 in conhost.exe: Microsoft C++ exception: wil::ResultException at memory location 0x000000EE660FDFB0.
</code></pre></div>
<p dir="auto">Stack trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 	KernelBase.dll!RaiseException�()	Unknown
 	ucrtbase.dll!_CxxThrowException�()	Unknown
 	conhost.exe!wil::details::ThrowResultExceptionInternal(struct wil::FailureInfo const &amp;)	Unknown
 	conhost.exe!wil::details::ReportFailure()	Unknown
 	conhost.exe!wil::details::ReportFailure_Hr(void *,unsigned int,char const *,char const *,char const *,void *,enum wil::FailureType,long)	Unknown
 	conhost.exe!wil::details::in1diag3::Throw_Hr(void *,unsigned int,char const *,long)	Unknown
 	conhost.exe!TextBufferCellIterator::TextBufferCellIterator()	Unknown
 	conhost.exe!RenderData::IsCursorDoubleWidth()	Unknown
 	conhost.exe!Microsoft::Console::Render::Renderer::_PaintFrameForEngine()	Unknown
 	conhost.exe!Microsoft::Console::Render::Renderer::PaintFrame()	Unknown
 	conhost.exe!Microsoft::Console::Render::RenderThread::_ThreadProc()	Unknown
 	kernel32.dll!BaseThreadInitThunk�()	Unknown
 	ntdll.dll!RtlUserThreadStart�()	Unknown"><pre class="notranslate"><code class="notranslate"> 	KernelBase.dll!RaiseException�()	Unknown
 	ucrtbase.dll!_CxxThrowException�()	Unknown
 	conhost.exe!wil::details::ThrowResultExceptionInternal(struct wil::FailureInfo const &amp;)	Unknown
 	conhost.exe!wil::details::ReportFailure()	Unknown
 	conhost.exe!wil::details::ReportFailure_Hr(void *,unsigned int,char const *,char const *,char const *,void *,enum wil::FailureType,long)	Unknown
 	conhost.exe!wil::details::in1diag3::Throw_Hr(void *,unsigned int,char const *,long)	Unknown
 	conhost.exe!TextBufferCellIterator::TextBufferCellIterator()	Unknown
 	conhost.exe!RenderData::IsCursorDoubleWidth()	Unknown
 	conhost.exe!Microsoft::Console::Render::Renderer::_PaintFrameForEngine()	Unknown
 	conhost.exe!Microsoft::Console::Render::Renderer::PaintFrame()	Unknown
 	conhost.exe!Microsoft::Console::Render::RenderThread::_ThreadProc()	Unknown
 	kernel32.dll!BaseThreadInitThunk�()	Unknown
 	ntdll.dll!RtlUserThreadStart�()	Unknown
</code></pre></div>
<p dir="auto">Presumably here: <a href="https://github.com/microsoft/terminal/blob/6c747c565b52b377410b317469efe3ef5e0beb50/src/buffer/out/textBufferCellIterator.cpp#L43">textBufferCellIterator.cpp</a></p>