Skip to content

BUG: prevent crash when TransformFileReader transform list is empty#40

Closed
ihnorton wants to merge 1 commit intoInsightSoftwareConsortium:masterfrom
ihnorton:prevent_matfile_reader_crash
Closed

BUG: prevent crash when TransformFileReader transform list is empty#40
ihnorton wants to merge 1 commit intoInsightSoftwareConsortium:masterfrom
ihnorton:prevent_matfile_reader_crash

Conversation

@ihnorton
Copy link
Contributor

@ihnorton ihnorton commented Mar 2, 2018

Fixes segfault reported here: https://discourse.slicer.org/t/loading-mat-matrix/2226
while reading MATLAB .mat file (into Slicer, but replicated independently) because ioTransformList is empty.

frame #0: 0x00000001148d4209 libITKIOTransformBase-4.13d.1.dylib`itk::TransformFileReaderTemplate<double>::Update(this=0x0000000146741000) at itkTransformFileReader.hxx:149
   146 	  // need to be initialized using the transform parameters.
   147 	  // kernelTransform->ComputeWMatrix() has to be called after the transform is read but
   148 	  // before the transform is used.
-> 149 	  std::string transformTypeName = ioTransformList.front()->GetNameOfClass();
   150 	  const size_t len = strlen("KernelTransform");// Computed at compile time in most cases
   151 	  if (transformTypeName.size() >= len
   152 	      && !transformTypeName.compare(transformTypeName.size()-len , len, "KernelTransform"))

@ihnorton
Copy link
Contributor Author

ihnorton commented Mar 2, 2018

FWIW

100% tests passed, 0 tests failed out of 2360

I guess CI failed due to compiler warnings.

@thewtex
Copy link
Member

thewtex commented Mar 5, 2018

@ihnorton Thanks for the patch. Could it please be submitted to Gerrit?

@ihnorton
Copy link
Contributor Author

ihnorton commented Mar 5, 2018

Alright... (I thought you were taking PRs based on some of the othere recent ones here)

@ihnorton ihnorton closed this Mar 5, 2018
@ihnorton ihnorton deleted the prevent_matfile_reader_crash branch March 5, 2018 17:37
@ihnorton
Copy link
Contributor Author

ihnorton commented Mar 5, 2018

@thewtex
Copy link
Member

thewtex commented Mar 6, 2018

Thanks, @ihnorton!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants