Skip to content

Commit 818380b

Browse files
authored
fix: freed eventPtr in AdminClient (#1836)
1 parent 8204917 commit 818380b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Confluent.Kafka/AdminClient.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ private Task StartPollTask(CancellationToken ct)
131131
while (true)
132132
{
133133
ct.ThrowIfCancellationRequested();
134-
134+
IntPtr eventPtr = IntPtr.Zero;
135135
try
136136
{
137-
var eventPtr = kafkaHandle.QueuePoll(resultQueue, this.cancellationDelayMaxMs);
137+
eventPtr = kafkaHandle.QueuePoll(resultQueue, this.cancellationDelayMaxMs);
138138
if (eventPtr == IntPtr.Zero)
139139
{
140140
continue;
@@ -351,6 +351,13 @@ private Task StartPollTask(CancellationToken ct)
351351
this.DisposeResources();
352352
break;
353353
}
354+
finally
355+
{
356+
if (eventPtr != IntPtr.Zero)
357+
{
358+
Librdkafka.event_destroy(eventPtr);
359+
}
360+
}
354361
}
355362
}
356363
catch (OperationCanceledException) {}

0 commit comments

Comments
 (0)