forked from zlib-ng/zlib-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add back-and-forth inflateCopy() test
Check that calling inflateCopy() twice does not result in memory corruption.
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* test_inflate_copy.cc - Test copying inflate stream */ | ||
|
||
#include "zbuild.h" | ||
#ifdef ZLIB_COMPAT | ||
# include "zlib.h" | ||
#else | ||
# include "zlib-ng.h" | ||
#endif | ||
|
||
#include "test_shared.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
TEST(inflate, copy_back_and_forth) { | ||
PREFIX3(stream) d1_stream, d2_stream; | ||
int err; | ||
|
||
memset(&d1_stream, 0, sizeof(d1_stream)); | ||
err = PREFIX(inflateInit2)(&d1_stream, MAX_WBITS + 14); | ||
ASSERT_EQ(err, Z_OK); | ||
err = PREFIX(inflateCopy)(&d2_stream, &d1_stream); | ||
ASSERT_EQ(err, Z_OK); | ||
err = PREFIX(inflateEnd)(&d1_stream); | ||
ASSERT_EQ(err, Z_OK); | ||
err = PREFIX(inflateCopy)(&d1_stream, &d2_stream); | ||
ASSERT_EQ(err, Z_OK); | ||
err = PREFIX(inflateEnd)(&d1_stream); | ||
ASSERT_EQ(err, Z_OK); | ||
err = PREFIX(inflateEnd)(&d2_stream); | ||
ASSERT_EQ(err, Z_OK); | ||
} |