Skip to content

Commit 50eb005

Browse files
committed
Merge branch 'cb/plug-leaks-in-alloca-emu-users'
Leakfix. * cb/plug-leaks-in-alloca-emu-users: t0000: avoid masking git exit value through pipes tree-diff: fix leak when not HAVE_ALLOCA_H
2 parents f7511fd + 66c0c44 commit 50eb005

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

t/t0000-basic.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,28 +1271,29 @@ P=$(test_oid root)
12711271

12721272
test_expect_success 'git commit-tree records the correct tree in a commit' '
12731273
commit0=$(echo NO | git commit-tree $P) &&
1274-
tree=$(git show --pretty=raw $commit0 |
1275-
sed -n -e "s/^tree //p" -e "/^author /q") &&
1274+
git show --pretty=raw $commit0 >out &&
1275+
tree=$(sed -n -e "s/^tree //p" -e "/^author /q" out) &&
12761276
test "z$tree" = "z$P"
12771277
'
12781278

12791279
test_expect_success 'git commit-tree records the correct parent in a commit' '
12801280
commit1=$(echo NO | git commit-tree $P -p $commit0) &&
1281-
parent=$(git show --pretty=raw $commit1 |
1282-
sed -n -e "s/^parent //p" -e "/^author /q") &&
1281+
git show --pretty=raw $commit1 >out &&
1282+
parent=$(sed -n -e "s/^parent //p" -e "/^author /q" out) &&
12831283
test "z$commit0" = "z$parent"
12841284
'
12851285

12861286
test_expect_success 'git commit-tree omits duplicated parent in a commit' '
12871287
commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&
1288-
parent=$(git show --pretty=raw $commit2 |
1289-
sed -n -e "s/^parent //p" -e "/^author /q" |
1290-
sort -u) &&
1288+
git show --pretty=raw $commit2 >out &&
1289+
cat >match.sed <<-\EOF &&
1290+
s/^parent //p
1291+
/^author /q
1292+
EOF
1293+
parent=$(sed -n -f match.sed out | sort -u) &&
12911294
test "z$commit0" = "z$parent" &&
1292-
numparent=$(git show --pretty=raw $commit2 |
1293-
sed -n -e "s/^parent //p" -e "/^author /q" |
1294-
wc -l) &&
1295-
test $numparent = 1
1295+
git show --pretty=raw $commit2 >out &&
1296+
test_stdout_line_count = 1 sed -n -f match.sed out
12961297
'
12971298

12981299
test_expect_success 'update-index D/F conflict' '

tree-diff.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
ALLOC_ARRAY((x), nr); \
2222
} while(0)
2323
#define FAST_ARRAY_FREE(x, nr) do { \
24-
if ((nr) > 2) \
24+
if ((nr) <= 2) \
25+
xalloca_free((x)); \
26+
else \
2527
free((x)); \
2628
} while(0)
2729

0 commit comments

Comments
 (0)