[Nut-upsdev] Memory leak in upsmon

Max E. Kuznecov mek at mek.uz.ua
Sat Jan 26 12:05:35 UTC 2008


Hello,

I was running upsmon some time without UPS connected and noticed
significant memory leak.
After some debugging I found the leak source. It is in file clients/upsclient.c.
Function upscli_connect() allocates memory for ups->pc_ctx and in case
of any error, just returns -1 without freeing it.
My NUT version is 2.2.0, but I quickly looked through 2.2.1 sources
and it seems this bug was not fixed.

So I include here simple patch. It uses goto to skip to free()
allocated memory before returning in case of error. Sure one could
rewrite it in more elegant way but nevertheless it helped me.

Regards.

-- 
~syhpoon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-upsclient.c
Type: text/x-csrc
Size: 2734 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20080126/dbe05dfe/attachment.c 


More information about the Nut-upsdev mailing list