Skip to content

Conversation

joshleeb
Copy link
Contributor

@joshleeb joshleeb commented Jul 6, 2019

This PR fixes the index out of bounds error that occurs when parsing
some specific timezones.

Tested by running the code to reproduce in #7 as well as compiling exa
with zoneinfo-compiled containing this patch to confirm that exa --long doesn't panic.

Resolves #7
Relevant downstream ogham/exa#517

This PR fixes the `index out of bounds` error that occurs when parsing
some specific timezones.

Tested by running the code to reproduce in #7 as well as compiling exa
with zoneinfo-compiled containing this patch to confirm that `exa
--long` doesn't panic.
@joshleeb
Copy link
Contributor Author

joshleeb commented Jul 6, 2019

I don't have much knowledge on zoneinfo files but this seems to fix the issue, and the downstream issue with exa, at least at the surface level.

@ogham ogham merged commit d43e28e into rust-datetime:master Jul 14, 2019
@ogham
Copy link
Collaborator

ogham commented Jul 14, 2019

Oh my god, I spent like an hour debugging this problem today because I didn't see this PR!

I've merged this because I prefer having those two expressions as variables now that I look at it. The good news is we ended up with pretty much the same solution:

transition_type:  flags_to_transition_type(tz.standard_flags.get(i).unwrap_or(&0) != &0,
                                           tz.gmt_flags.get(i).unwrap_or(&0) != &0),

I wanted to look up how the official zoneinfo code handles this case, and the code confirms that if those values are missing, they should be assumed to be 0: https://github.com/eggert/tz/blob/f9bd527016f806611e58a99d759d00c64c46a938/tzfile.h#L70-L80

Anyway, thanks for this. I'm going to publish a release today to fix the exa issue.

@ogham
Copy link
Collaborator

ogham commented Jul 14, 2019

v0.4.8 is out

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.

Failed to parse some specific timezones
2 participants