maskit commented on a change in pull request #2814: Fix memory issue in cpp 
ZTSClient
URL: https://github.com/apache/pulsar/pull/2814#discussion_r226946881
 
 

 ##########
 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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to