[zeromq-dev] memory leak in zmq_poll()?

Kamil Shakirov kamils80 at gmail.com
Fri Jan 8 15:36:43 CET 2010


On Jan 8, 2010, at 8:15 PM, Martin Sustrik wrote:

> Hi Kamil,
> 
> Yes. You are right. Are you happy to submit the patch under MIT license?
> 

Sure. ;-)

> Thanks.
> Martin
> 
>> When returning from zmq_poll() with timeout the allocated pollset
>> doesn't get freed. Checked with valgrind.
>> diff --git a/src/zmq.cpp b/src/zmq.cpp
>> index 62ee562..92ddef1 100644
>> --- a/src/zmq.cpp
>> +++ b/src/zmq.cpp
>> @@ -338,8 +338,10 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_,
>> long tim
>>         errno_assert (rc >= 0);
>>          //  If timeout was hit with no events signaled, return zero.
>> -        if (!initial && rc == 0)
>> +        if (!initial && rc == 0) {
>> +            free (pollfds);
>>             return 0;
>> +       }
>>          //  From now on, perform blocking polling.
>>         initial = false;
> 

--wbr




More information about the zeromq-dev mailing list