Author: cazfi Date: Thu Apr 28 19:22:59 2016 New Revision: 32524 URL: http://svn.gna.org/viewcvs/freeciv?rev=32524&view=rev Log: Refactored libcurl usage so that we never try to set NULL for CURLOPT_ERRORBUFFER.
See bug #24603 Modified: branches/S2_6/utility/netfile.c Modified: branches/S2_6/utility/netfile.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/netfile.c?rev=32524&r1=32523&r2=32524&view=diff ============================================================================== --- branches/S2_6/utility/netfile.c (original) +++ branches/S2_6/utility/netfile.c Thu Apr 28 19:22:59 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,6 +37,8 @@ typedef size_t (*netfile_write_cb)(char *ptr, size_t size, size_t nmemb, void *userdata); +static char error_buf_curl[CURL_ERROR_SIZE]; + /********************************************************************** Set handle to usable state. ***********************************************************************/ @@ -51,6 +53,9 @@ curl_easy_reset(handle); } + error_buf_curl[0] = '\0'; + curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, error_buf_curl); + return handle; } @@ -81,7 +86,6 @@ CURLcode curlret; struct curl_slist *headers = NULL; static CURL *handle; - char errorbuf[CURL_ERROR_SIZE] = ""; bool ret = TRUE; handle = netfile_init_handle(); @@ -99,7 +103,6 @@ } curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errorbuf); curlret = curl_easy_perform(handle); @@ -113,15 +116,12 @@ /* TRANS: first %s is URL, second is Curl error message * (not in Freeciv translation domain) */ _("Failed to fetch %s: %s"), URL, - strlen(errorbuf) ? errorbuf : curl_easy_strerror(curlret)); + error_buf_curl[0] != '\0' ? error_buf_curl : curl_easy_strerror(curlret)); cb(buf, data); } ret = FALSE; } - - /* Just in case next user of Curl handle doesn't reset it */ - curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, NULL); return ret; } _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits