]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow for empty write buffers
authorAlan T. DeKok <aland@freeradius.org>
Sun, 25 Feb 2024 12:40:52 +0000 (07:40 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 28 Feb 2024 15:23:46 +0000 (10:23 -0500)
src/lib/bio/mem.c

index 78d93ae9233a4cf3d63854eef8db8b8409d76421..f626ee553ad30ea3e7057842df55a861afb96bc2 100644 (file)
@@ -672,13 +672,18 @@ fr_bio_t *fr_bio_mem_alloc(TALLOC_CTX *ctx, size_t read_size, size_t write_size,
        /*
         *      The caller has to state that the API is caching data both ways.
         */
-       if (!read_size || !write_size) return NULL;
+       if (!read_size) return NULL;
 
        if (!fr_bio_mem_buf_alloc(my, &my->read_buffer, read_size)) return NULL;
-       if (!fr_bio_mem_buf_alloc(my, &my->write_buffer, write_size)) return NULL;
-
        my->bio.read = fr_bio_mem_read;
-       my->bio.write = fr_bio_mem_write_next;
+
+       if (write_size) {
+               if (!fr_bio_mem_buf_alloc(my, &my->write_buffer, write_size)) return NULL;
+
+               my->bio.write = fr_bio_mem_write_next;
+       } else {
+               my->bio.write = fr_bio_next_write;
+       }
 
        fr_bio_chain(&my->bio, next);