Copy the url string before passing it to curl.

This commit is contained in:
lotodore
2008-04-22 22:41:31 +00:00
parent d7c6cdd75c
commit 440460cce1
+3 -2
View File
@@ -30,6 +30,7 @@ struct DownloadData
CURL *curlHandle; CURL *curlHandle;
CURLM *curlMultiHandle; CURLM *curlMultiHandle;
FILE *targetFile; FILE *targetFile;
string curlUrl;
}; };
@@ -54,8 +55,8 @@ DownloadHelper::Init(const string &url, const string &targetFileName)
//m_data->curlMultiHandle = curl_multi_init(); //m_data->curlMultiHandle = curl_multi_init();
// TODO throw exception on error // TODO throw exception on error
m_data->curlUrl = url;
curl_easy_setopt(m_data->curlHandle, CURLOPT_URL, url.c_str()); curl_easy_setopt(m_data->curlHandle, CURLOPT_URL, m_data->curlUrl.c_str());
curl_easy_setopt(m_data->curlHandle, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(m_data->curlHandle, CURLOPT_WRITEFUNCTION, NULL);
curl_easy_setopt(m_data->curlHandle, CURLOPT_WRITEDATA, m_data->targetFile); curl_easy_setopt(m_data->curlHandle, CURLOPT_WRITEDATA, m_data->targetFile);