pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] maskit commented on a change in pull request #2814: Fix memory issue in cpp ZTSClient
Date Mon, 22 Oct 2018 18:28:03 GMT
maskit commented on a change in pull request #2814: Fix memory issue in cpp ZTSClient
URL: https://github.com/apache/pulsar/pull/2814#discussion_r226947435
 
 

 ##########
 File path: pulsar-client-cpp/lib/auth/athenz/ZTSClient.cc
 ##########
 @@ -143,7 +143,7 @@ std::string ZTSClient::ybase64Encode(const unsigned char *input, int
length) {
 char *ZTSClient::base64Decode(const char *input) {
     BIO *bio, *b64;
     size_t length = strlen(input);
-    char *result = (char *)malloc(length);
+    char *result = (char *)calloc(length, sizeof(char));
 
 Review comment:
   I have no idea how long `input` is and how many times this function will be called, but
we should consider the overhead of initialization.
   
   Also, in this particular case, `result[length] = '\0';` would look more purposeful because
we want to return a null terminated string.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message