summaryrefslogtreecommitdiff
path: root/tests/patch/patch_common.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-10-19 15:42:54 +0200
committerPatrick Steinhardt <ps@pks.im>2019-10-19 17:02:53 +0200
commit223e7e43efffdcab4da864413e70eff40e8ada46 (patch)
tree75c191885996bd8f4a07dee3409bb920a20d9689 /tests/patch/patch_common.h
parentb246bed5ab83035d8aef95f1b7ff10dd746db7cb (diff)
downloadlibgit2-223e7e43efffdcab4da864413e70eff40e8ada46.tar.gz
patch_parse: reject patches with multiple old/new paths
It's currently possible to have patches with multiple old path name headers. As we didn't check for this case, this resulted in a memory leak when overwriting the old old path with the new old path because we simply discarded the old pointer. Instead of fixing this by free'ing the old pointer, we should reject such patches altogether. It doesn't make any sense for the "---" or "+++" markers to occur multiple times within a patch n the first place. This also implicitly fixes the memory leak.
Diffstat (limited to 'tests/patch/patch_common.h')
-rw-r--r--tests/patch/patch_common.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/patch/patch_common.h b/tests/patch/patch_common.h
index d730d142c..68b183d38 100644
--- a/tests/patch/patch_common.h
+++ b/tests/patch/patch_common.h
@@ -905,3 +905,10 @@
"-b\n" \
"+bb\n" \
" c\n"
+
+#define PATCH_MULTIPLE_OLD_PATHS \
+ "diff --git \n" \
+ "--- \n" \
+ "+++ \n" \
+ "index 0000..7DDb\n" \
+ "--- \n"