Fix issue with C++ endf float converter #7
Merged
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.
This closes #6 - at least for me, I noticed someone having similar issues in #4.
The crash seems to be a seg fault that occurs when the endf float being converted is negative, i.e. has a leading minus sign.
Positive numbers have leading whitespace so hit the continue statement and j is not incremented. Therefore, the first digit is placed at arr[0]. However, negative numbers had the leading minus sign placed at arr[0] and first digit at arr[1]. This means when the null terminator is placed at the end, for negative numbers this is at arr[12] so the crash occurs.
EDIT: my initial commit was not the correct solution, I think it is simply a case of increasing arr to be length 13 so it has space for both the e and null terminator if the input buffer is length 11. Apologies, some how my initial incorrect fix ran (I have no idea how!) but on restarting it failed.
This would seem to me to be an issue across systems.