From 7a5a8093c43f5d7dd24ca4fe8e0ed92d75101bbe Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 8 Mar 2016 12:46:15 +0100 Subject: [PATCH] Fix curl crash --- code/nel/src/gui/group_html.cpp | 8 +++++--- code/ryzom/client/src/login_patch.cpp | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 7ae9870e5..1b5e36964 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -305,7 +305,7 @@ namespace NLGUI return; } - FILE *fp = nlfopen (tmpdest, "wb"); + FILE *fp = nlfopen(tmpdest, "wb"); if (fp == NULL) { curl_easy_cleanup(curl); @@ -316,7 +316,8 @@ namespace NLGUI curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); curl_easy_setopt(curl, CURLOPT_URL, finalUrl.c_str()); - curl_easy_setopt(curl, CURLOPT_FILE, fp); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); curl_multi_add_handle(MultiCurl, curl); Curls.push_back(CDataDownload(curl, finalUrl, dest, fp, ImgType, img, "", "", style)); @@ -423,7 +424,8 @@ namespace NLGUI curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curl, CURLOPT_FILE, fp); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); curl_multi_add_handle(MultiCurl, curl); Curls.push_back(CDataDownload(curl, url, dest, fp, BnpType, NULL, script, md5sum)); diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 20bfcbed0..baf7044df 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -1414,7 +1414,8 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL); throw Exception ("Can't open file '%s' for writing: code=%d %s (error code 37)", dest.c_str (), errno, strerror(errno)); } - curl_easy_setopt(curl, CURLOPT_FILE, fp); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); //CurrentFilesToGet++;