Browse Source

Fix memory leak.

Free the buffer holding the URL in the get_file function of the libcurl
module. Also refactor that function to avoid checking the return value
of curl functions guaranteed to always return CURLOK.
master
Damien Goutte-Gattat 2 months ago
parent
commit
09c240535f
  1. 10
      src/scheme-libcurl.c

10
src/scheme-libcurl.c

@ -77,13 +77,10 @@ gfsec_scheme_libcurl_get_file(gfsec_scheme_t scheme,
scheme == GFSEC_SCHEME_HTTP ? "" : "s",
authority, path);
if ( curl_easy_setopt(curl, CURLOPT_URL, url) != 0 )
ret = GFSEC_SCHEME_STATUS_ERROR;
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&data);
if ( ret == 0 && curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb) != 0 )
ret = GFSEC_SCHEME_STATUS_ERROR;
if ( ret == 0 && curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&data) != 0 )
if ( curl_easy_setopt(curl, CURLOPT_URL, url) != 0 )
ret = GFSEC_SCHEME_STATUS_ERROR;
if ( ret == 0 && curl_easy_perform(curl) != 0 )
@ -95,6 +92,7 @@ gfsec_scheme_libcurl_get_file(gfsec_scheme_t scheme,
}
curl_easy_cleanup(curl);
free(url);
return ret;
}

Loading…
Cancel
Save