Unverified Commit cb17630b by Edward Thomson Committed by GitHub

Merge pull request #5338 from pks-t/pks/patch-null-arithmetic

patch_parse: fix undefined behaviour due to arithmetic on NULL pointers
parents e1d7747f c6f9ad73
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment