8000 Merge pull request #3865 from libgit2/ethomson/leaks · libgit2/libgit2@152efee · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 152efee

Browse files
author
Edward Thomson
authored
Merge pull request #3865 from libgit2/ethomson/leaks
Fix leaks, some warnings and an error
2 parents a37624e + df87648 commit 152efee

File tree

14 files changed

+407
-354
lines changed

14 files changed

+407
-354
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ v0.24 + 1
5454

5555
### Breaking API changes
5656

57+
* `git_packbuilder_object_count` and `git_packbuilder_written` now
58+
return a `size_t` instead of a `uint32_t` for more thorough
59+
compatibility with the rest of the library.
60+
61+
* `git_packbuiler_progress` now provides explicitly sized `uint32_t`
62+
values instead of `unsigned int`.
63+
5764
v0.24
5865
-------
5966

include/git2/pack.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,21 +196,21 @@ GIT_EXTERN(int) git_packbuilder_foreach(git_packbuilder *pb, git_packbuilder_for
196196
* @param pb the packbuilder
197197
* @return the number of objects in the packfile
198198
*/
199-
GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb);
199+
GIT_EXTERN(size_t) git_packbuilder_object_count(git_packbuilder *pb);
200200

201201
/**
202202
* Get the number of objects the packbuilder has already written out
203203
*
204204
* @param pb the packbuilder
205205
* @return the number of objects which have already been written
206206
*/
207-
GIT_EXTERN(uint32_t) git_packbuilder_written(git_packbuilder *pb);
207+
GIT_EXTERN(size_t) git_packbuilder_written(git_packbuilder *pb);
208208

209209
/** Packbuilder progress notification function */
210210
typedef int (*git_packbuilder_progress)(
211211
int stage,
212-
unsigned int current,
213-
unsigned int total,
212+
uint32_t current,
213+
uint32_t total,
214214
void *payload);
215215

216216
/**

src/apply.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ static int patch_image_init_fromstr(
5353
for (start = in; start < in + in_len; start = end) {
5454
end = memchr(start, '\n', in_len);
5555

56-
if (end < in + in_len)
56+
if (end == NULL)
57+
end = in + in_len;
58+
59+
else if (end < in + in_len)
5760
end++;
5861

5962
line = git_pool_mallocz(&out->pool, 1);
@@ -97,7 +100,7 @@ static bool match_hunk(
97100
git_diff_line *preimage_line = git_vector_get(&preimage->lines, i);
98101
git_diff_line *image_line = git_vector_get(&image->lines, linenum + i);
99102

100-
if (preimage_line->content_len != preimage_line->content_len ||
103+
if (preimage_line->content_len != image_line->content_len ||
101104
memcmp(preimage_line->content, image_line->content, image_line->content_len) != 0) {
102105
match = 0;
103106
break;

src/crlf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ static int crlf_check(
289289
ca.eol = check_eol(attr_values[1]); /* eol */
290290
}
291291
ca.auto_crlf = GIT_AUTO_CRLF_DEFAULT;
292+
ca.safe_crlf = GIT_SAFE_CRLF_DEFAULT;
292293

293294
/*
294295
* Use the core Git logic to see if we should perform CRLF for this file

src/index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,12 +2160,12 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
21602160

21612161
if (git__strtol64(&tmp, buffer, &endptr, 8) < 0 ||
21622162
!endptr || endptr == buffer || *endptr ||
2163-
tmp < 0) {
2163+
tmp < 0 || tmp > UINT32_MAX) {
21642164
index_entry_reuc_free(lost);
21652165
return index_error_invalid("reading reuc entry stage");
21662166
}
21672167

2168-
lost->mode[i] = tmp;
2168+
lost->mode[i] = (uint32_t)tmp;
21692169

21702170
len = (endptr + 1) - buffer;
21712171
if (size <= len) {

0 commit comments

Comments
 (0)
0