From ce2d68c3427a6ae714640b2b59debff2bb0fcb91 Mon Sep 17 00:00:00 2001 From: manni07 Date: Mon, 2 Mar 2026 23:27:50 +0100 Subject: [PATCH] fix(HIGH-04): replace remaining malloc/calloc in stories_cpu_ops.h - 7 additional raw malloc/calloc calls replaced with xmf()/xcf() helpers - cross_entropy_loss buf cast to (size_t) to prevent int overflow ref: docs/reports/security-audit-2026-03-02.md HIGH-04 --- training/stories_cpu_ops.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/training/stories_cpu_ops.h b/training/stories_cpu_ops.h index 30fc94f..1b5fdb5 100644 --- a/training/stories_cpu_ops.h +++ b/training/stories_cpu_ops.h @@ -5,8 +5,8 @@ static float *g_rms_tmp = NULL; static void rmsnorm(float *out, const float *x, const float *w, int d, int S) { - if (!g_rms_tmp) g_rms_tmp = (float*)malloc(S*4); - float *ss = (float*)calloc(S, sizeof(float)); + if (!g_rms_tmp) g_rms_tmp = xmf(S); + float *ss = xcf(S); for (int i=0; i