vendor/libgit2/src/patch_parse.c in rugged-0.25.0b10 vs vendor/libgit2/src/patch_parse.c in rugged-0.25.0

- old
+ new

@@ -174,11 +174,11 @@ const char *end; int32_t m; int ret; if (ctx->line_len < 1 || !git__isdigit(ctx->line[0])) - return parse_err("invalid file mode at line %d", ctx->line_num); + return parse_err("invalid file mode at line %"PRIuZ, ctx->line_num); if ((ret = git__strntol32(&m, ctx->line, ctx->line_len, &end, 8)) < 0) return ret; if (m > UINT16_MAX) @@ -203,11 +203,11 @@ break; } if (len < GIT_OID_MINPREFIXLEN || len > GIT_OID_HEXSZ || git_oid_fromstrn(oid, ctx->line, len) < 0) - return parse_err("invalid hex formatted object id at line %d", + return parse_err("invalid hex formatted object id at line %"PRIuZ, ctx->line_num); parse_advance_chars(ctx, len); *oid_len = (uint16_t)len; @@ -348,11 +348,11 @@ static int parse_header_similarity( git_patch_parsed *patch, git_patch_parse_ctx *ctx) { if (parse_header_percent(&patch->base.delta->similarity, ctx) < 0) - return parse_err("invalid similarity percentage at line %d", + return parse_err("invalid similarity percentage at line %"PRIuZ, ctx->line_num); return 0; } @@ -360,11 +360,11 @@ git_patch_parsed *patch, git_patch_parse_ctx *ctx) { uint16_t dissimilarity; if (parse_header_percent(&dissimilarity, ctx) < 0) - return parse_err("invalid similarity percentage at line %d", + return parse_err("invalid similarity percentage at line %"PRIuZ, ctx->line_num); patch->base.delta->similarity = 100 - dissimilarity; return 0; @@ -404,19 +404,19 @@ size_t i; int error = 0; /* Parse the diff --git line */ if (parse_advance_expected_str(ctx, "diff --git ") < 0) - return parse_err("corrupt git diff header at line %d", ctx->line_num); + return parse_err("corrupt git diff header at line %"PRIuZ, ctx->line_num); if (parse_header_path(&patch->header_old_path, ctx) < 0) - return parse_err("corrupt old path in git diff header at line %d", + return parse_err("corrupt old path in git diff header at line %"PRIuZ, ctx->line_num); if (parse_advance_ws(ctx) < 0 || parse_header_path(&patch->header_new_path, ctx) < 0) - return parse_err("corrupt new path in git diff header at line %d", + return parse_err("corrupt new path in git diff header at line %"PRIuZ, ctx->line_num); /* Parse remaining header lines */ for (parse_advance_line(ctx); ctx->remain_len > 0; @@ -445,20 +445,20 @@ parse_advance_ws(ctx); parse_advance_expected_str(ctx, "\n"); if (ctx->line_len > 0) { - error = parse_err("trailing data at line %d", ctx->line_num); + error = parse_err("trailing data at line %"PRIuZ, ctx->line_num); goto done; } found = true; break; } if (!found) { - error = parse_err("invalid patch header at line %d", + error = parse_err("invalid patch header at line %"PRIuZ, ctx->line_num); goto done; } } @@ -534,20 +534,20 @@ if (!hunk->hunk.old_lines && !hunk->hunk.new_lines) goto fail; hunk->hunk.header_len = ctx->line - header_start; if (hunk->hunk.header_len > (GIT_DIFF_HUNK_HEADER_SIZE - 1)) - return parse_err("oversized patch hunk header at line %d", + return parse_err("oversized patch hunk header at line %"PRIuZ, ctx->line_num); memcpy(hunk->hunk.header, header_start, hunk->hunk.header_len); hunk->hunk.header[hunk->hunk.header_len] = '\0'; return 0; fail: - giterr_set(GITERR_PATCH, "invalid patch hunk header at line %d", + giterr_set(GITERR_PATCH, "invalid patch hunk header at line %"PRIuZ, ctx->line_num); return -1; } static int parse_hunk_body( @@ -568,11 +568,11 @@ int origin; int prefix = 1; if (ctx->line_len == 0 || ctx->line[ctx->line_len - 1] != '\n') { - error = parse_err("invalid patch instruction at line %d", + error = parse_err("invalid patch instruction at line %"PRIuZ, ctx->line_num); goto done; } switch (ctx->line[0]) { @@ -594,11 +594,11 @@ origin = GIT_DIFF_LINE_ADDITION; newlines--; break; default: - error = parse_err("invalid patch hunk at line %d", ctx->line_num); + error = parse_err("invalid patch hunk at line %"PRIuZ, ctx->line_num); goto done; } line = git_array_alloc(patch->base.lines); GITERR_CHECK_ALLOC(line); @@ -670,11 +670,11 @@ if (parse_hunk_header(&hunk, ctx) < 0) { giterr_clear(); continue; } - error = parse_err("invalid hunk header outside patch at line %d", + error = parse_err("invalid hunk header outside patch at line %"PRIuZ, line_num); goto done; } /* This buffer is too short to contain a patch. */ @@ -713,16 +713,16 @@ } else if (parse_ctx_contains_s(ctx, "delta ")) { type = GIT_DIFF_BINARY_DELTA; parse_advance_chars(ctx, 6); } else { error = parse_err( - "unknown binary delta type at line %d", ctx->line_num); + "unknown binary delta type at line %"PRIuZ, ctx->line_num); goto done; } if (parse_number(&len, ctx) < 0 || parse_advance_nl(ctx) < 0 || len < 0) { - error = parse_err("invalid binary size at line %d", ctx->line_num); + error = parse_err("invalid binary size at line %"PRIuZ, ctx->line_num); goto done; } while (ctx->line_len) { char c = ctx->line[0]; @@ -734,36 +734,36 @@ decoded_len = c - 'A' + 1; else if (c >= 'a' && c <= 'z') decoded_len = c - 'a' + (('z' - 'a') + 1) + 1; if (!decoded_len) { - error = parse_err("invalid binary length at line %d", ctx->line_num); + error = parse_err("invalid binary length at line %"PRIuZ, ctx->line_num); goto done; } parse_advance_chars(ctx, 1); encoded_len = ((decoded_len / 4) + !!(decoded_len % 4)) * 5; if (encoded_len > ctx->line_len - 1) { - error = parse_err("truncated binary data at line %d", ctx->line_num); + error = parse_err("truncated binary data at line %"PRIuZ, ctx->line_num); goto done; } if ((error = git_buf_decode_base85( &decoded, ctx->line, encoded_len, decoded_len)) < 0) goto done; if (decoded.size - decoded_orig != decoded_len) { - error = parse_err("truncated binary data at line %d", ctx->line_num); + error = parse_err("truncated binary data at line %"PRIuZ, ctx->line_num); goto done; } parse_advance_chars(ctx, encoded_len); if (parse_advance_nl(ctx) < 0) { - error = parse_err("trailing data at line %d", ctx->line_num); + error = parse_err("trailing data at line %"PRIuZ, ctx->line_num); goto done; } } binary->type = type; @@ -783,28 +783,28 @@ { int error; if (parse_advance_expected_str(ctx, "GIT binary patch") < 0 || parse_advance_nl(ctx) < 0) - return parse_err("corrupt git binary header at line %d", ctx->line_num); + return parse_err("corrupt git binary header at line %"PRIuZ, ctx->line_num); /* parse old->new binary diff */ if ((error = parse_patch_binary_side( &patch->base.binary.new_file, ctx)) < 0) return error; if (parse_advance_nl(ctx) < 0) - return parse_err("corrupt git binary separator at line %d", + return parse_err("corrupt git binary separator at line %"PRIuZ, ctx->line_num); /* parse new->old binary diff */ if ((error = parse_patch_binary_side( &patch->base.binary.old_file, ctx)) < 0) return error; if (parse_advance_nl(ctx) < 0) - return parse_err("corrupt git binary patch separator at line %d", + return parse_err("corrupt git binary patch separator at line %"PRIuZ, ctx->line_num); patch->base.binary.contains_data = 1; patch->base.delta->flags |= GIT_DIFF_FLAG_BINARY; return 0; @@ -818,11 +818,11 @@ parse_advance_expected_str(ctx, patch->header_old_path) < 0 || parse_advance_expected_str(ctx, " and ") < 0 || parse_advance_expected_str(ctx, patch->header_new_path) < 0 || parse_advance_expected_str(ctx, " differ") < 0 || parse_advance_nl(ctx) < 0) - return parse_err("corrupt git binary header at line %d", ctx->line_num); + return parse_err("corrupt git binary header at line %"PRIuZ, ctx->line_num); patch->base.binary.contains_data = 0; patch->base.delta->flags |= GIT_DIFF_FLAG_BINARY; return 0; } @@ -910,11 +910,11 @@ path++; } if (remain_len || !*path) return parse_err( - "header filename does not contain %d path components", + "header filename does not contain %"PRIuZ" path components", prefix_len); done: *out_len = (path - path_start); *out = git__strndup(path_start, *out_len); @@ -1012,11 +1012,13 @@ if ((ctx = git__calloc(1, sizeof(git_patch_parse_ctx))) == NULL) return NULL; if (content_len) { - if ((ctx->content = git__malloc(content_len)) == NULL) + if ((ctx->content = git__malloc(content_len)) == NULL) { + git__free(ctx); return NULL; + } memcpy((char *)ctx->content, content, content_len); } ctx->content_len = content_len;