summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-01-20 22:15:09 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-22 00:04:16 +0100
commit57d36d3f0cbbf641bb67f7f183edcb52aa15180d (patch)
tree00a43786d1ce004676b7bb4965ca047167abdb69
parentb5241296f8600ea3ba962c45ed8038abec5343f1 (diff)
downloadqtbase-57d36d3f0cbbf641bb67f7f183edcb52aa15180d.tar.gz
qtbase-57d36d3f0cbbf641bb67f7f183edcb52aa15180d.tar.bz2
qtbase-57d36d3f0cbbf641bb67f7f183edcb52aa15180d.zip
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 <ogoffart@woboq.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
-rw-r--r--src/testlib/qtestcase.cpp7
1 files changed, 3 insertions, 4 deletions
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<char *>(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<char *>(malloc(size));
result[size - 1] = '\0';
}