Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff: fix enum value being out of allowed range #4680

Merged
merged 1 commit into from
Jun 12, 2018

Conversation

pks-t
Copy link
Member

@pks-t pks-t commented Jun 12, 2018

The C89 standard states in §6.7.2.2 "Enumeration specifiers":

The expression that defines the value of an enumeration constant shall
be an integer constant expression that has a value representable as an
int.

On most platforms, this effectively limits the range to a 32 bit signed
integer. The enum git_diff_option_t though recently gained an entry
GIT_DIFF_INDENT_HEURISTIC = (1u << 31), which breaks this limit.

Fix the issue by using a gap in git_diff_option_t's enum values. While
this has the benefit of retaining our API, it may break applications
which do not get recompiled after upgrading libgit2. But as we are
bumping the soversion on each release anyway and thus force a recompile
of dependents, this is not a problem.


Fixes #4657

The C89 standard states in §6.7.2.2 "Enumeration specifiers":

> The expression that defines the value of an enumeration constant shall
> be an integer constant expression that has a value representable as an
> int.

On most platforms, this effectively limits the range to a 32 bit signed
integer. The enum `git_diff_option_t` though recently gained an entry
`GIT_DIFF_INDENT_HEURISTIC = (1u << 31)`, which breaks this limit.

Fix the issue by using a gap in `git_diff_option_t`'s enum values. While
this has the benefit of retaining our API, it may break applications
which do not get recompiled after upgrading libgit2. But as we are
bumping the soversion on each release anyway and thus force a recompile
of dependents, this is not a problem.
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.

None yet

2 participants