From: Alan T. DeKok Date: Sun, 25 Feb 2024 12:40:52 +0000 (-0500) Subject: allow for empty write buffers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cdc39eef72b53f6dc4d2691f5bbe85973bdda3b;p=thirdparty%2Ffreeradius-server.git allow for empty write buffers --- diff --git a/src/lib/bio/mem.c b/src/lib/bio/mem.c index 78d93ae9233..f626ee553ad 100644 --- a/src/lib/bio/mem.c +++ b/src/lib/bio/mem.c @@ -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);