]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
src and dst may be the same
authorAlan T. DeKok <aland@freeradius.org>
Tue, 13 Feb 2018 15:52:36 +0000 (10:52 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 14 Feb 2018 13:16:15 +0000 (08:16 -0500)
src/lib/io/ring_buffer.c

index 8e8648e6104ea194cc59b501b9cfa40d83e29e12..ab6c7426be079ec1954a32066848c02cd9d187d5 100644 (file)
@@ -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.
         */