summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien DARRAGON <adarragon@haproxy.com>2023-05-11 15:28:20 +0200
committerChristopher Faulet <cfaulet@haproxy.com>2023-05-12 09:45:30 +0200
commitceb13b5ed33271dfd7e8a324263bef9eddc733f6 (patch)
tree5ca2e7358ab9b0314b64597f4aa055ffad101ce1
parent94df1b57ee0e2f3df97c0348f52ea7c74d98e12a (diff)
downloadhaproxy-ceb13b5ed33271dfd7e8a324263bef9eddc733f6.tar.gz
MINOR: ncbuf: missing malloc checks in standalone code
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.
-rw-r--r--src/ncbuf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/ncbuf.c b/src/ncbuf.c
index a96cf598e..e1452f1d2 100644
--- a/src/ncbuf.c
+++ b/src/ncbuf.c
@@ -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");