From 3fd6439f571a56771c6bbc21fa638cb94c929cc3 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 6 Feb 2017 23:16:39 -0500 Subject: Fix a memory leak parsing -printf --- printf.c | 1 + tests.sh | 8 +++++++- tests/test_0141.out | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/test_0141.out diff --git a/printf.c b/printf.c index 7ee0dc1..08522db 100644 --- a/printf.c +++ b/printf.c @@ -731,6 +731,7 @@ done: goto error; } + dstrfree(literal); return command; error: diff --git a/tests.sh b/tests.sh index f24308d..a6d9784 100755 --- a/tests.sh +++ b/tests.sh @@ -852,9 +852,15 @@ function test_0140() { bfs_diff basic basic -quit -print } +function test_0141() { + # Memory leak regression test + [ "$GNU" ] || return 0 + bfs_diff basic -maxdepth 0 -printf '%p' +} + result=0 -for i in {1..140}; do +for i in {1..141}; do test="test_$(printf '%04d' $i)" if [ -t 1 ]; then diff --git a/tests/test_0141.out b/tests/test_0141.out new file mode 100644 index 0000000..15a13db --- /dev/null +++ b/tests/test_0141.out @@ -0,0 +1 @@ +basic -- cgit v1.2.3