Skip to content

Fix ASAN error use-after-free in vtkSEPReader

The previous implementation os vtkSEPReader (introduced by PRs !4909 (merged) and !4938 (merged)) has a use-after-free error, as detected by AddressSanitizer.

The function vtkSEPReader::ReplaceFileName(..) started with:

  delete[] this->FileName;

and that means that the string pointed by FileName was destroyed. Even if the value of FileName was stored in the local variable fileName, in vtkSEPReader::RequestData, the string pointed by it was destroyed!

The patch of this commit is a lot simpler: both the string pointed by FileName and the one that will replace it already exist in memory, and will not be modified during the run of RequestData. So we can just swap the pointers, without any need of memory allocation/deallocation to copy the strings.

Cc: @maxGimeno @jpouderoux @michael.migliore @ben.boeckel

Edited by Laurent Rineau

Merge request reports