Skip to content

Commit 5de5935

Browse files
authored
Fixes opaque data memory leak on producer error (#954)
1 parent 8f046ea commit 5de5935

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/producer.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,17 @@ NAN_METHOD(Producer::NodeProduce) {
629629
error_code = static_cast<int>(b.err());
630630
}
631631

632+
if (error_code != 0 && opaque) {
633+
// If there was an error enqueing this message, there will never
634+
// be a delivery report for it, so we have to clean up the opaque
635+
// data now, if there was any.
636+
637+
Nan::Persistent<v8::Value> *persistent =
638+
static_cast<Nan::Persistent<v8::Value> *>(opaque);
639+
persistent->Reset();
640+
delete persistent;
641+
}
642+
632643
if (key != NULL) {
633644
delete key;
634645
}

0 commit comments

Comments
 (0)