Skip to content

Commit

Permalink
fix segmentation failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
shibd committed Dec 4, 2023
1 parent 6b97ee8 commit 7d15f51
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Consumer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,13 @@ Napi::Value Consumer::BatchReceive(const Napi::CallbackInfo &info) {
Napi::Array jsArray = Napi::Array::New(env, listSize);
for (int i = 0; i < listSize; i++) {
pulsar_message_t *rawMessage = pulsar_messages_get(rawMessages, i);
pulsar_message_t *message = pulsar_message_create();
pulsar_message_copy(rawMessage, message);
Napi::Object obj = Message::NewInstance(
{}, std::shared_ptr<pulsar_message_t>(rawMessage, pulsar_message_free));
{}, std::shared_ptr<pulsar_message_t>(message, pulsar_message_free));
jsArray.Set(i, obj);
}
pulsar_messages_free(rawMessages);
return jsArray;
});
}
Expand Down

0 comments on commit 7d15f51

Please sign in to comment.