aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2015-10-12 21:07:41 +0300
committerLasse Collin <lasse.collin@tukaani.org>2016-06-28 21:09:46 +0300
commit35f189673e280c12e4c5129f9f97e54eef3bbc04 (patch)
tree08cbd3895674b724602d820348a680439b74b632 /tests
parentliblzma: Fix lzma_index_dup() for empty Streams. (diff)
downloadxz-35f189673e280c12e4c5129f9f97e54eef3bbc04.tar.xz
Tests: Add tests for the two bugs fixed in index.c.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_index.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_index.c b/tests/test_index.c
index 06b4d6ba..ce2cfe10 100644
--- a/tests/test_index.c
+++ b/tests/test_index.c
@@ -630,6 +630,22 @@ test_corrupt(void)
}
+// Allocator that succeeds for the first two allocation but fails the rest.
+static void *
+my_alloc(void *opaque, size_t a, size_t b)
+{
+ (void)opaque;
+
+ static unsigned count = 0;
+ if (++count > 2)
+ return NULL;
+
+ return malloc(a * b);
+}
+
+static const lzma_allocator my_allocator = { &my_alloc, NULL, NULL };
+
+
int
main(void)
{
@@ -655,5 +671,19 @@ main(void)
test_corrupt();
+ // Test for the bug fix 21515d79d778b8730a434f151b07202d52a04611:
+ // liblzma: Fix lzma_index_dup() for empty Streams.
+ i = create_empty();
+ expect(lzma_index_stream_padding(i, 4) == LZMA_OK);
+ test_copy(i);
+ lzma_index_end(i, NULL);
+
+ // Test for the bug fix 3bf857edfef51374f6f3fffae3d817f57d3264a0:
+ // liblzma: Fix a memory leak in error path of lzma_index_dup().
+ // Use Valgrind to see that there are no leaks.
+ i = create_small();
+ expect(lzma_index_dup(i, &my_allocator) == NULL);
+ lzma_index_end(i, NULL);
+
return 0;
}