]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ncbuf: missing malloc checks in standalone code
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 11 May 2023 13:28:20 +0000 (15:28 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 May 2023 07:45:30 +0000 (09:45 +0200)
Some malloc resulsts were not checked in standalone ncbuf code.

As this is debug/test code, we don't need to explicitly handle memory
errors, we just add some BUG_ON() to ensure that memory is properly
allocated and prevent unexpected results.

This partially fixes issue GH #2130.

No backport needed.

src/ncbuf.c

index a96cf598ed7d2fa5ecde2f1ba4e1a362d3dca26d..e1452f1d27c819e3652e8c7818d10b66f3e3de66 100644 (file)
@@ -810,9 +810,11 @@ static int ncbuf_test(ncb_sz_t head, int reset, int print_delay)
        enum ncb_ret ret;
 
        data0 = malloc(bufsize);
+       BUG_ON(!data0);
        memset(data0, 0xff, bufsize);
 
        bufarea = malloc(bufsize);
+       BUG_ON(!bufarea);
 
        fprintf(stderr, "running unit tests\n");