diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 09:30:51 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 09:30:51 +0000 |
commit | ded8a26aa08aae51e4bae9fe34ccf1410dcb55cb (patch) | |
tree | e5cdd967a7fd6843a0e535ef655d0306f2d3663d /fast_encoder.cc | |
parent | Adding debian version 1.12-2. (diff) | |
download | lzip-ded8a26aa08aae51e4bae9fe34ccf1410dcb55cb.tar.xz lzip-ded8a26aa08aae51e4bae9fe34ccf1410dcb55cb.zip |
Merging upstream version 1.13~rc1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r-- | fast_encoder.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fast_encoder.cc b/fast_encoder.cc index 4574379..ba7c34c 100644 --- a/fast_encoder.cc +++ b/fast_encoder.cc @@ -60,12 +60,14 @@ Fmatchfinder::Fmatchfinder( const int ifd ) const int buffer_size_limit = ( 16 * dict_size ) + before_size + after_size; buffer_size = dict_size; buffer = (uint8_t *)std::malloc( buffer_size ); - if( !buffer ) throw std::bad_alloc(); + if( !buffer ) { delete[] prev_positions; throw std::bad_alloc(); } if( read_block() && !at_stream_end && buffer_size < buffer_size_limit ) { buffer_size = buffer_size_limit; - buffer = (uint8_t *)std::realloc( buffer, buffer_size ); - if( !buffer ) throw std::bad_alloc(); + uint8_t * const tmp = (uint8_t *)std::realloc( buffer, buffer_size ); + if( !tmp ) + { std::free( buffer ); delete[] prev_positions; throw std::bad_alloc(); } + buffer = tmp; read_block(); } if( at_stream_end && stream_pos < dict_size ) @@ -73,7 +75,9 @@ Fmatchfinder::Fmatchfinder( const int ifd ) else dictionary_size_ = dict_size; pos_limit = buffer_size; if( !at_stream_end ) pos_limit -= after_size; - prev_pos_chain = new int32_t[dictionary_size_]; + prev_pos_chain = new( std::nothrow ) int32_t[dictionary_size_]; + if( !prev_pos_chain ) + { std::free( buffer ); delete[] prev_positions; throw std::bad_alloc(); } for( int i = 0; i < num_prev_positions; ++i ) prev_positions[i] = -1; } |