esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
unsigned long long offset, unsigned long long *length)
{
- char *range = NULL;
+ g_autofree char *range = NULL;
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
int responseCode = 0;
virMutexUnlock(&curl->lock);
if (responseCode < 0) {
- goto cleanup;
+ return -1;
} else if (responseCode != 200 && responseCode != 206) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("HTTP response code %d for download from '%s'"),
responseCode, url);
- goto cleanup;
+ return -1;
}
if (length)
*content = virBufferContentAndReset(&buffer);
- cleanup:
- VIR_FREE(range);
-
if (!(*content))
return -1;