From 6d97cdf25db274a81e9d9edc417b51cf44152733 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 2 Jun 2011 18:41:23 +0300 Subject: Fix some memory leaks and missing initialisations. --- src/utils/base64.cpp | 7 ++++--- src/utils/copynpaste.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/utils') diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index d3563fb78..14876d878 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -49,8 +49,8 @@ unsigned char *php3_base64_encode(const unsigned char *string, { const unsigned char *current = string; int i = 0; - unsigned char *result = static_cast(malloc( - ((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char))); + unsigned char *result = static_cast(calloc( + ((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char), 1)); while (length > 2) { /* keep going until we have less than 24 bits */ @@ -99,7 +99,8 @@ unsigned char *php3_base64_decode(const unsigned char *string, int ch, i = 0, j = 0, k; char *chp; - unsigned char *result = static_cast(malloc(length + 1)); + unsigned char *result = static_cast( + calloc(length + 1, 1)); if (result == NULL) return NULL; diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 58740a243..5b1ccb5bc 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -57,7 +57,7 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) if (len > 0) { // Convert from UTF-16 to UTF-8 - void *temp = malloc(len); + void *temp = calloc(len, 1); if (WideCharToMultiByte(CP_UTF8, 0, data, -1, (LPSTR)temp, len, NULL, NULL)) { -- cgit v1.2.3-60-g2f50