Skip to content

Commit 899d8dc

Browse files
committed
Merge branch 'maint-1.6.0' into maint
* maint-1.6.0: test-path-utils: Fix off by one, found by valgrind get_sha1_basic(): fix invalid memory access, found by valgrind
2 parents 5c41531 + b8469ad commit 899d8dc

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sha1_name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
309309

310310
/* basic@{time or number} format to query ref-log */
311311
reflog_len = at = 0;
312-
if (str[len-1] == '}') {
312+
if (len && str[len-1] == '}') {
313313
for (at = 0; at < len - 1; at++) {
314314
if (str[at] == '@' && str[at+1] == '{') {
315315
reflog_len = (len-1) - (at+2);

test-path-utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
int main(int argc, char **argv)
44
{
55
if (argc == 3 && !strcmp(argv[1], "normalize_absolute_path")) {
6-
char *buf = xmalloc(strlen(argv[2])+1);
6+
char *buf = xmalloc(PATH_MAX + 1);
77
int rv = normalize_absolute_path(buf, argv[2]);
88
assert(strlen(buf) == rv);
99
puts(buf);

0 commit comments

Comments
 (0)