From bf8c3b4a239af35b0d09320fe8a9039d8b7f079a Mon Sep 17 00:00:00 2001 From: Inuyasha-fan <927463646@qq.com> Date: Thu, 13 Nov 2025 08:54:12 +0000 Subject: [PATCH] fix: prevent array out-of-bounds write in segv function.Add boundary checks to ensure array indices do not exceed the allocated size. --- include/xsf/specfun/specfun.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/xsf/specfun/specfun.h b/include/xsf/specfun/specfun.h index 62476018f7..e550a3a1f7 100644 --- a/include/xsf/specfun/specfun.h +++ b/include/xsf/specfun/specfun.h @@ -6055,10 +6055,14 @@ namespace specfun { } } cv0[k - 1] = x1; + int index = 0; if (l == 0) - eg[2 * k - 2] = cv0[k - 1]; + index = 2 * k - 2; if (l == 1) - eg[2 * k - 1] = cv0[k - 1]; + index = 2 * k - 1; + // boundary check + if (index >= n - m + 1) break; + eg[index] = cv0[k - 1]; } } *cv = eg[n - m];