vendor/libgit2/src/patch_parse.c in rugged-0.26.0b5 vs vendor/libgit2/src/patch_parse.c in rugged-0.26.0
- old
+ new
@@ -442,13 +442,13 @@
if ((error = op->fn(patch, ctx)) < 0)
goto done;
parse_advance_ws(ctx);
- parse_advance_expected_str(ctx, "\n");
- if (ctx->line_len > 0) {
+ if (parse_advance_expected_str(ctx, "\n") < 0 ||
+ ctx->line_len > 0) {
error = parse_err("trailing data at line %"PRIuZ, ctx->line_num);
goto done;
}
found = true;
@@ -560,11 +560,12 @@
int oldlines = hunk->hunk.old_lines;
int newlines = hunk->hunk.new_lines;
for (;
- ctx->remain_len > 4 && (oldlines || newlines) &&
- memcmp(ctx->line, "@@ -", 4) != 0;
+ ctx->remain_len > 1 &&
+ (oldlines || newlines) &&
+ (ctx->remain_len <= 4 || memcmp(ctx->line, "@@ -", 4) != 0);
parse_advance_line(ctx)) {
int origin;
int prefix = 1;