tcksift2: Fix check for allocation of memory for weights vector #2672
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If path to output weights file is erroneous, do not issue a misleading warning message claiming that the issue relates to an inability to allocate memory.
Fixes bug introduced in #626.
Solves #2668.
Replaces #2671.
Classic case of why you should not catch exceptions in a manner that is broad in both scope of exception type and length of code.
Note that even though the output weights vector is the primary output of the
tcksift2command, there was nevertheless a conscious decision in the past to nevertheless allow the rest of the command to complete even if there were a memory failure at this point. There might be other outputs that could be of use. Or for instance, the user may have requested that the streamline weighting coefficients be exported, which don't require allocation of additional memory to write, and the weighting factors can be computed from those after the fact.