From b07be42e9f9b3de7e014a7f914d0e57dabd5d00e Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Mon, 28 Mar 2016 11:41:39 +0200 Subject: [PATCH] noux: fix leak in pipe ring buffer Fixes #1923 --- repos/ports/src/noux/pipe_io_channel.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/repos/ports/src/noux/pipe_io_channel.h b/repos/ports/src/noux/pipe_io_channel.h index 2d8a080ff2..5495532b6f 100644 --- a/repos/ports/src/noux/pipe_io_channel.h +++ b/repos/ports/src/noux/pipe_io_channel.h @@ -5,7 +5,7 @@ */ /* - * Copyright (C) 2012-2013 Genode Labs GmbH + * Copyright (C) 2012-2016 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU General Public License version 2. @@ -133,9 +133,12 @@ namespace Noux { memcpy(dst, &_buffer[_read_offset], upper_len); size_t const lower_len = min(dst_len - upper_len, _write_offset); - memcpy(dst + upper_len, &_buffer[0], lower_len); - - _read_offset = lower_len; + if (lower_len) { + memcpy(dst + upper_len, &_buffer[0], lower_len); + _read_offset = lower_len; + } else { + _read_offset += upper_len; + } _wake_up_writer(); return upper_len + lower_len;