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; }