From: Alan T. DeKok Date: Tue, 13 Feb 2018 15:52:36 +0000 (-0500) Subject: src and dst may be the same X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b69610cc8d20c90adefa3871f3dc272f70209a78;p=thirdparty%2Ffreeradius-server.git src and dst may be the same --- diff --git a/src/lib/io/ring_buffer.c b/src/lib/io/ring_buffer.c index 8e8648e6104..ab6c7426be0 100644 --- a/src/lib/io/ring_buffer.c +++ b/src/lib/io/ring_buffer.c @@ -344,6 +344,14 @@ uint8_t *fr_ring_buffer_reserve_split(fr_ring_buffer_t *dst, size_t reserve_size p = fr_ring_buffer_reserve(dst, reserve_size); if (!p) return NULL; + /* + * Alloc and reserve in the same ring buffer. Maybe + * there's no need to memcpy() the data? + */ + if ((src == dst) && (p == (src->buffer + src->write_offset))) { + return 0; + } + /* * Copy the data from the old buffer to the new one. */