rpm-software-management / librepo

A library providing C and Python (libcURL like) API for downloading packages and linux repository metadata in rpm-md format
http://rpm-software-management.github.io/librepo/
GNU Lesser General Public License v2.1
75 stars 91 forks source link

fastestmirror: Fix memory leak #208

Closed tinez closed 3 years ago

tinez commented 3 years ago

I ran clang's 'scan-build' on the code base and it found a potential memory leak.

If any of the two 'curl_easy_setopt' calls in the loop fails, we'll leak the recently created 'mirror' object. This object is not really needed until the moment of appending it to 'list'. This patch delays the creation of the 'mirror' object, so there won't be a code path that leaks it.