diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2019-12-14 06:59:19 +1030 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-14 06:59:19 +1030 |
| commit | cb17630b75dbdc502c21da8e73641fa932bc8c6b (patch) | |
| tree | 0f1d48e962be89eb003d5a10518eef701cf94f47 /src | |
| parent | e1d7747f23a3b2c09976c00685a754563ad6225e (diff) | |
| parent | c6f9ad73e25f2abb1c25d50795b0b571305d43a4 (diff) | |
| download | libgit2-cb17630b75dbdc502c21da8e73641fa932bc8c6b.tar.gz | |
Merge pull request #5338 from pks-t/pks/patch-null-arithmetic
patch_parse: fix undefined behaviour due to arithmetic on NULL pointers
Diffstat (limited to 'src')
| -rw-r--r-- | src/patch_parse.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/patch_parse.c b/src/patch_parse.c index 7e2cc6383..9d089ad83 100644 --- a/src/patch_parse.c +++ b/src/patch_parse.c @@ -1025,13 +1025,17 @@ static int check_filenames(git_patch_parsed *patch) /* Prefer the rename filenames as they are unambiguous and unprefixed */ if (patch->rename_old_path) patch->base.delta->old_file.path = patch->rename_old_path; - else + else if (prefixed_old) patch->base.delta->old_file.path = prefixed_old + old_prefixlen; + else + patch->base.delta->old_file.path = NULL; if (patch->rename_new_path) patch->base.delta->new_file.path = patch->rename_new_path; - else + else if (prefixed_new) patch->base.delta->new_file.path = prefixed_new + new_prefixlen; + else + patch->base.delta->new_file.path = NULL; if (!patch->base.delta->old_file.path && !patch->base.delta->new_file.path) |
