From 57d36d3f0cbbf641bb67f7f183edcb52aa15180d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 20 Jan 2014 22:15:09 -0800 Subject: Fix mix of new[] / malloc in QTest::toHexRepresentation toHexRepresentation is used in QTest::toString(), whose results are deallocated with free(). So we shouldn't allocate with new[]. Change-Id: I3e9d35b3f28a1b9bfe740a13b5daa414b67853c6 Reviewed-by: Olivier Goffart Reviewed-by: Robin Burchell --- src/testlib/qtestcase.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index e170d2a044..2c8b7b20b7 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1893,7 +1893,7 @@ char *toHexRepresentation(const char *ba, int length) if (length > maxLen) { const int size = len * 3 + 4; - result = new char[size]; + result = static_cast(malloc(size)); char *const forElipsis = result + size - 5; forElipsis[0] = ' '; @@ -1901,10 +1901,9 @@ char *toHexRepresentation(const char *ba, int length) forElipsis[2] = '.'; forElipsis[3] = '.'; result[size - 1] = '\0'; - } - else { + } else { const int size = len * 3; - result = new char[size]; + result = static_cast(malloc(size)); result[size - 1] = '\0'; } -- cgit v1.2.3