From 0527471a527945157154b21f82203460a50dea3f Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Mon, 16 Oct 2017 19:14:31 +0200 Subject: [PATCH] Matrix: adjust buffer size calculation to account for additional characters Note: If the buffer is too small there's no memory corruption because of the snprintf limit but part of the output gets missing. --- matrix/Matrix.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix/Matrix.hpp b/matrix/Matrix.hpp index 26fd13153f..2428f9d246 100644 --- a/matrix/Matrix.hpp +++ b/matrix/Matrix.hpp @@ -286,7 +286,7 @@ public: void print() const { - static const size_t n = 10*N*M; + static const size_t n = 11*N*M + M; // for every entry a tab and 10 digits, for every row a newline char * buf = new char[n]; write_string(buf, n); printf("%s\n", buf);