]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
return errors
authorAlan T. DeKok <aland@freeradius.org>
Sat, 30 Mar 2024 14:55:48 +0000 (10:55 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 30 Mar 2024 22:13:45 +0000 (18:13 -0400)
src/lib/bio/mem.c

index 48dfb421a571871324c792f2f17c873c395cc421..e916be9b9487d777b10e365b4ba278fa9fc794d7 100644 (file)
@@ -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 {