From 7a8011bb28c0469bff2c9f838aacba2fa2df53e2 Mon Sep 17 00:00:00 2001 From: Eksan0325 <163502586+Eksan0325@users.noreply.github.com> Date: Fri, 12 Jun 2026 19:47:28 +0800 Subject: [PATCH] fix: Fix NULL dereference in ecx_mbxreceive when mailbox pool is empty Fix segfault in ecx_mbxreceive on exhausted mailbox pool (Issue#948) --- src/ec_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ec_main.c b/src/ec_main.c index c8d0335..0d09432 100644 --- a/src/ec_main.c +++ b/src/ec_main.c @@ -1671,7 +1671,12 @@ int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft **mbx, int ti if ((wkc > 0) && ((SMstat & 0x08) > 0)) /* read mailbox available ? */ { mbxro = slavelist->mbx_ro; - mbxin = ecx_getmbx(context); + mbxin = ecx_getmbx(context); + if (mbxin == NULL) + { + *mbx = NULL; + return 0; + } mbxh = (ec_mbxheadert *)mbxin; do {