This is an automated email from the ASF dual-hosted git repository.

massakam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git


The following commit(s) were added to refs/heads/master by this push:
     new 1bd357d  fix leak MessageId::ToString (#159)
1bd357d is described below

commit 1bd357d71461c7a451fb8fb8da5750e7eb530433
Author: Yuto Furuta <[email protected]>
AuthorDate: Tue Jun 1 16:29:42 2021 +0900

    fix leak MessageId::ToString (#159)
    
    Co-authored-by: Yuto Furuta <[email protected]>
---
 src/MessageId.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/MessageId.cc b/src/MessageId.cc
index ad9a195..82d88bb 100644
--- a/src/MessageId.cc
+++ b/src/MessageId.cc
@@ -17,6 +17,8 @@
  * under the License.
  */
 
+#include <stdlib.h>
+
 #include "MessageId.h"
 #include <pulsar/c/message.h>
 #include <pulsar/c/message_id.h>
@@ -117,7 +119,10 @@ Napi::Value MessageId::Deserialize(const 
Napi::CallbackInfo &info) {
 pulsar_message_id_t *MessageId::GetCMessageId() { return this->cMessageId; }
 
 Napi::Value MessageId::ToString(const Napi::CallbackInfo &info) {
-  return Napi::String::New(info.Env(), 
pulsar_message_id_str(this->cMessageId));
+  char *cStr = pulsar_message_id_str(this->cMessageId);
+  std::string s(cStr);
+  free(cStr);
+  return Napi::String::New(info.Env(), s);
 }
 
 MessageId::~MessageId() {

Reply via email to