diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 07:49:43 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 07:49:43 +0000 |
commit | 083c902a1bf6cd876dd4f683b7936a8246ec0cd9 (patch) | |
tree | a92dad44f2bad587e83d4080a70414d089367286 /testsuite/unzcrash.cc | |
parent | Adding debian version 1.10-1. (diff) | |
download | lzip-083c902a1bf6cd876dd4f683b7936a8246ec0cd9.tar.xz lzip-083c902a1bf6cd876dd4f683b7936a8246ec0cd9.zip |
Merging upstream version 1.11.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'testsuite/unzcrash.cc')
-rw-r--r-- | testsuite/unzcrash.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/testsuite/unzcrash.cc b/testsuite/unzcrash.cc index f61f8a8..7d10b28 100644 --- a/testsuite/unzcrash.cc +++ b/testsuite/unzcrash.cc @@ -16,7 +16,7 @@ a bug. Compile this file with the command: - g++ -O2 -Wall -W -o unzcrash testsuite/unzcrash.cc + g++ -Wall -W -O2 -o unzcrash testsuite/unzcrash.cc */ #include <csignal> @@ -26,9 +26,9 @@ #include <unistd.h> -int main( const int argc, const char * argv[] ) +int main( const int argc, const char * const argv[] ) { - if( argc < 3 ) + if( argc != 3 ) { std::fprintf( stderr, "Usage: unzcrash \"lzip -tv\" filename.lz\n" ); return 1; @@ -41,8 +41,8 @@ int main( const int argc, const char * argv[] ) return 1; } - const int buffer_size = 1 << 20; - uint8_t buffer[buffer_size]; + const int buffer_size = 1 << 21; + uint8_t * const buffer = new uint8_t[buffer_size]; const int size = std::fread( buffer, 1, buffer_size, f ); if( size >= buffer_size ) { @@ -64,7 +64,7 @@ int main( const int argc, const char * argv[] ) return 1; } - signal( SIGPIPE, SIG_IGN ); + std::signal( SIGPIPE, SIG_IGN ); for( int byte = 0; byte < size; ++byte ) { @@ -81,5 +81,6 @@ int main( const int argc, const char * argv[] ) ++buffer[byte]; } + delete[] buffer; return 0; } |