From 86a9d16c4f7fe550ee5e27df68a1191a3b6aac61 Mon Sep 17 00:00:00 2001 From: Kristin Date: Sat, 22 Nov 2025 12:41:41 +0100 Subject: [PATCH] addmatrix mit broadcasten --- matrix.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/matrix.c b/matrix.c index 2a33d14..7d0a649 100644 --- a/matrix.c +++ b/matrix.c @@ -33,6 +33,11 @@ void setMatrixAt(const MatrixType value, Matrix matrix, const unsigned int rowIdx, // Kopie der Matrix wird übergeben const unsigned int colIdx) { + if (rowIdx >= matrix.rows || + colIdx >= matrix.cols) { // Speichergröße nicht überschreiten + return; + } + matrix.buffer[rowIdx * matrix.cols + colIdx] = value; // rowIdx * matrix.cols -> Beginn der Zeile colIdx ->Spalte // innerhalb der Zeile