From d6e32c56160c6d384b1ecd70d6338f724a3571aa Mon Sep 17 00:00:00 2001 From: Daniel Hammerschmid Date: Mon, 27 Aug 2018 19:25:08 +0200 Subject: [PATCH] Limited max write block size of BufferedLimitedMemoryWriter The maximum block size written by the BufferedLimitedMemoryWriter is now limited to buffer_size. --- src/open_dmlib.vala | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/open_dmlib.vala b/src/open_dmlib.vala index 2c89385..2dec7fe 100755 --- a/src/open_dmlib.vala +++ b/src/open_dmlib.vala @@ -1249,7 +1249,22 @@ namespace OpenDMLib public override void write( uint8[] buf ) throws Error { - this.write_buffer( buf ); + if ( buf.length > this.buffer_size ) + { + for ( uint64 i = 0; i < buf.length; i += this.buffer_size ) + { + uint64 slice_end = i + this.buffer_size; + if ( slice_end > buf.length ) + { + slice_end = buf.length; + } + this.write_buffer( buf[ i : slice_end ] ); + } + } + else + { + this.write_buffer( buf ); + } this.buffer_index = 0; }