From 04493332f739e0cd68c9c4f10582403116a425be Mon Sep 17 00:00:00 2001 From: Lukas Weber Date: Thu, 20 Nov 2025 16:44:35 +0100 Subject: [PATCH] First error fixing in createMatrix() --- matrix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matrix.c b/matrix.c index 1659c86..55bbda1 100644 --- a/matrix.c +++ b/matrix.c @@ -10,7 +10,10 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) Matrix newMatrix; newMatrix.rows = rows; newMatrix.cols = cols; - newMatrix.buffer = calloc(rows*cols, sizeof(MatrixType)); + if (rows == 0 || cols == 0) + newMatrix.buffer = NULL; + else + newMatrix.buffer = calloc(rows*cols, sizeof(MatrixType)); return newMatrix; }