diff options
author | Ben Straub <bs@github.com> | 2012-11-30 03:16:19 +0400 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2012-12-01 01:12:15 +0400 |
commit | ca901e7b0fb38a7f4748ff5fcde7a2779f3a7771 (patch) | |
tree | 71c7897510fe859e984290703be756e21810a894 /src/diff_tform.c | |
parent | 2f8d30becb4801d869188d2d46ca1512843e8698 (diff) |
Deploy GIT_DIFF_FIND_OPTIONS_INIT
Diffstat (limited to 'src/diff_tform.c')
-rw-r--r-- | src/diff_tform.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c index 987d4b8e6..1df041044 100644 --- a/src/diff_tform.c +++ b/src/diff_tform.c @@ -168,6 +168,18 @@ int git_diff_merge( return error; } +static bool find_opts_has_valid_version(const git_diff_find_options *opts) +{ + if (!opts) + return true; + + if (opts->version > 0 && opts->version <= GIT_DIFF_FIND_OPTIONS_VERSION) + return true; + + giterr_set(GITERR_INVALID, "Invalid version %d on git_diff_find_options", opts->version); + return false; +} + #define DEFAULT_THRESHOLD 50 #define DEFAULT_BREAK_REWRITE_THRESHOLD 60 #define DEFAULT_TARGET_LIMIT 200 @@ -187,7 +199,8 @@ static int normalize_find_opts( if (given != NULL) memcpy(opts, given, sizeof(*opts)); else { - memset(opts, 0, sizeof(*opts)); + git_diff_find_options init = GIT_DIFF_FIND_OPTIONS_INIT; + memmove(opts, &init, sizeof(init)); opts->flags = GIT_DIFF_FIND_RENAMES; @@ -198,6 +211,9 @@ static int normalize_find_opts( opts->flags = GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES; } + if (!find_opts_has_valid_version(opts)) + return -1; + /* some flags imply others */ if (opts->flags & GIT_DIFF_FIND_RENAMES_FROM_REWRITES) |