From: Alan T. DeKok Date: Sat, 30 Mar 2024 14:55:48 +0000 (-0400) Subject: return errors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de412bfc1cc3ffc7de20e774e05c44716b0e06c0;p=thirdparty%2Ffreeradius-server.git return errors --- diff --git a/src/lib/bio/mem.c b/src/lib/bio/mem.c index 48dfb421a57..e916be9b948 100644 --- a/src/lib/bio/mem.c +++ b/src/lib/bio/mem.c @@ -668,13 +668,20 @@ 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) return NULL; + if (!read_size) { + fr_strerror_const("Read size must be non-zero"); + return NULL; + } - if (!fr_bio_mem_buf_alloc(my, &my->read_buffer, read_size)) return NULL; + if (!fr_bio_mem_buf_alloc(my, &my->read_buffer, read_size)) { + oom: + fr_strerror_const("Out of memory"); + return NULL; + } my->bio.read = fr_bio_mem_read; if (write_size) { - if (!fr_bio_mem_buf_alloc(my, &my->write_buffer, write_size)) return NULL; + if (!fr_bio_mem_buf_alloc(my, &my->write_buffer, write_size)) goto oom; my->bio.write = fr_bio_mem_write_next; } else {