Update nesting level data type from u16 to u32 to avoid attempt to add with overflow panic #934
+5
−5
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.
I need to parse large XML files (50MB+) that represent traffic information following the DATEX II schema. The content of the XML looks like this:
There can be several thousands of
<situation>. I deserialize usingquick_xmlversion 0.39 into custom struct:But when I attempt to do so with the largest files I get a panic:
This is the line that caused it
where
nesting_levelis au16that ends up overflowing.This patch fixes the issue by simply moving to
u32. I am not familiar with this library so I am not sure if there are other implications, please feel free to suggest better alternatives. As a workaround I can use my fork with this commit or I could stream all the situations and deserialize one by one using this version of the library, but I'd rather avoid that.