summaryrefslogtreecommitdiffstats
path: root/testsuite/unzcrash.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 07:49:37 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 07:49:37 +0000
commit867c3a558780e371ffc835ac5dc19613fb177233 (patch)
treee388646a6bb73561a4b9c864bf8d38629f1d1bcd /testsuite/unzcrash.cc
parentAdding upstream version 1.10. (diff)
downloadlzip-867c3a558780e371ffc835ac5dc19613fb177233.tar.xz
lzip-867c3a558780e371ffc835ac5dc19613fb177233.zip
Adding upstream version 1.11.upstream/1.11
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'testsuite/unzcrash.cc')
-rw-r--r--testsuite/unzcrash.cc13
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;
}