From 7e7bfbae3ff5843065c9dbaa64a1ef80bf263fb5 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 6 Nov 2026 22:52:55 +0100 Subject: [PATCH] Test MatrixFailsOnZeroDimensions --- Startcode/matrix.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Startcode/matrix.c b/Startcode/matrix.c index cf04771..03e5b3e 100644 --- a/Startcode/matrix.c +++ b/Startcode/matrix.c @@ -7,15 +7,17 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) { Matrix m; - m.rows = rows; - m.cols = cols; + if(rows == 0|| cols == 0) // Zeile oder Spalte = 0, dann keine Speicher anfordern, sonder Buffer auf NULL setzen - { + { + m.rows = 0; + m.cols = 0; m.buffer = NULL; return m; } - + m.rows = rows; + m.cols = cols; m.buffer = (MatrixType*) calloc(rows * cols, sizeof(MatrixType)); // calloc, statt malloc benutzt, um direkt alle Werte mit 0 zu initialisieren return m; }