<div dir="ltr">Thanks for the nice report Axel. I created a MR, now in testing to fix this.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 19, 2018 at 6:58 AM, Axel Kittenberger <span dir="ltr"><<a href="mailto:axkibe@gmail.com" target="_blank">axkibe@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>The JPEGReader in 8.1.1 crashes when the output vertical extend is smaller than the whole image. Reason is: outExt[2] and [3] weren't even looked at in the code and it always filled up the whole vertical size going out of allocated outPtr size.</div><div><br></div><div>Below patch fixes it for me. I also posted this in the bug tracker, but dunno what is the supposed way for this.</div><div><br></div><div>Kind regards, Axel</div><div><br></div><div>diff -ru <a href="http://VTK-8.1.1.org/IO/Image/vtkJPEGReader.cxx" target="_blank">VTK-8.1.1.org/IO/Image/<wbr>vtkJPEGReader.cxx</a> VTK-8.1.1/IO/Image/<wbr>vtkJPEGReader.cxx</div><div>--- <a href="http://VTK-8.1.1.org/IO/Image/vtkJPEGReader.cxx" target="_blank">VTK-8.1.1.org/IO/Image/<wbr>vtkJPEGReader.cxx</a><span style="white-space:pre-wrap"> </span>2018-05-11 16:34:24.000000000 +0200</div><div>+++ VTK-8.1.1/IO/Image/<wbr>vtkJPEGReader.cxx<span style="white-space:pre-wrap">   </span>2018-07-19 12:37:04.697053464 +0200</div><div>@@ -295,19 +295,23 @@</div><div> </div><div>   // read the bulk data</div><div>   long outSize = cinfo.output_components*(<wbr>outExt[1] - outExt[0] + 1);</div><div>+  unsigned int line = cinfo.output_height - 1;</div><div>+  outPtr += outSize*(outExt[3] - outExt[2] - 1);</div><div>   while (cinfo.output_scanline < cinfo.output_height)</div><div>   {</div><div>     JDIMENSION linesRead = jpeg_read_scanlines(&cinfo, row_pointers, maxChunk);</div><div> </div><div>     // copy the data into the outPtr</div><div>-    OT *outPtr2 = outPtr + (cinfo.output_height - cinfo.output_scanline)*outInc[<wbr>1];</div><div>-    for (unsigned int i = 0; i < linesRead; ++i)</div><div>+    for (unsigned int i = linesRead; i > 0; --i)</div><div>     {</div><div>-      memcpy(outPtr2,</div><div>-             row_pointers[linesRead - i - 1]</div><div>-             + outExt[0]*cinfo.output_<wbr>components,</div><div>-             outSize);</div><div>-      outPtr2 += outInc[1];</div><div>+<span style="white-space:pre-wrap">     </span>  if( line >= outExt[2] && line < outExt[3] )</div><div>+<span style="white-space:pre-wrap">    </span>  {</div><div>+<span style="white-space:pre-wrap">    </span>      memcpy(outPtr,</div><div>+    <span style="white-space:pre-wrap">   </span>         row_pointers[i - 1] + outExt[0]*cinfo.output_<wbr>components,</div><div>+            <span style="white-space:pre-wrap">     </span> outSize);</div><div>+          outPtr -= outInc[1];</div><div>+<span style="white-space:pre-wrap">   </span>  }</div><div>+<span style="white-space:pre-wrap">    </span>  line--;</div><div>     }</div><div>   }</div><div><br></div><div><br></div><div>This code raises the segfault without above patch:</div><div><br></div><div><div>#include <vtkImageClip.h></div><div>#include <vtkJPEGReader.h></div><div><br></div><div>int main( int argc, char** argv )</div><div>{</div><div>    vtkJPEGReader * reader = vtkJPEGReader::New( );</div><div>    reader->SetFileName( "test.jpg" );</div><div>    reader->UpdateInformation( );</div><div><br></div><div>    vtkImageClip * clip = vtkImageClip::New( );</div><div>    clip->SetInputConnection( reader->GetOutputPort( ) );</div><div>    clip->SetOutputWholeExtent( 0, 10, 0, 10, 0, 1 );</div><div>    clip->Update( );</div><div><br></div><div>    return 0;</div><div>}</div></div><div><br></div><div>test.jpg being any large enough image.</div></div>
<br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtk-developers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtk-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://public.kitware.com/mailman/listinfo/vtk-developers" rel="noreferrer" target="_blank">https://public.kitware.com/<wbr>mailman/listinfo/vtk-<wbr>developers</a><br>
<br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Ken Martin PhD<div>Distinguished Engineer<br><span style="font-size:12.8px">Kitware Inc.</span><br></div><div>101 East Weaver Street<br>Carrboro, North Carolina<br>
27510 USA<br><br><div><span style="font-size:10pt;font-family:Tahoma,sans-serif">This communication,
including all attachments, contains confidential and legally privileged
information, and it is intended only for the use of the addressee.  Access to this email by anyone else is
unauthorized. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken in reliance on it is prohibited and may be
unlawful. If you received this communication in error please notify us
immediately and destroy the original message. 
Thank you.</span></div></div></div></div></div></div></div>
</div>