From 37dccf8a2b671caf0c576db1c36d3cafc7fb15dd Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Wed, 1 Dec 2021 08:53:31 -0600 Subject: [PATCH] Gracefully deal with malloc failures in module_ctx.h --- src/lib/server/module_ctx.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/server/module_ctx.h b/src/lib/server/module_ctx.h index 904c7a733af..60ec5bf0393 100644 --- a/src/lib/server/module_ctx.h +++ b/src/lib/server/module_ctx.h @@ -71,7 +71,8 @@ static module_ctx_t *module_ctx_from_inst(TALLOC_CTX *ctx, module_inst_ctx_t con { module_ctx_t *nmctx; - MEM(nmctx = talloc_zero(ctx, module_ctx_t)); + nmctx = talloc_zero(ctx, module_ctx_t); + if (unlikely(!nmctx)) return NULL; nmctx->inst = mctx->inst; return nmctx; @@ -84,7 +85,8 @@ static module_ctx_t *module_ctx_from_thread_inst(TALLOC_CTX *ctx, module_thread_ { module_ctx_t *nmctx; - MEM(nmctx = talloc_zero(ctx, module_ctx_t)); + nmctx = talloc_zero(ctx, module_ctx_t); + if (unlikely(!nmctx)) return NULL; nmctx->inst = mctx->inst; nmctx->thread = mctx->thread; @@ -99,6 +101,7 @@ static module_ctx_t *module_ctx_dup(TALLOC_CTX *ctx, module_ctx_t const *mctx) module_ctx_t *nmctx; nmctx = talloc_zero(ctx, module_ctx_t); + if (unlikely(!nmctx)) return NULL; memcpy(nmctx, mctx, sizeof(*nmctx)); return nmctx; -- 2.47.3