From: Daniel Stenberg Date: Mon, 9 Sep 2024 07:15:56 +0000 (+0200) Subject: content_encoding: avoid getting all encodings unless necessary X-Git-Tag: curl-8_10_0~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=63ebc48b69223b401647d08cc8db2834a718bffb;p=thirdparty%2Fcurl.git content_encoding: avoid getting all encodings unless necessary The error_do_write() function may very well return witout needing the listing of all encoding types so postpone that call until it is needed. Closes #14831 --- diff --git a/lib/content_encoding.c b/lib/content_encoding.c index 734547d006..c0b97f1f7d 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -909,18 +909,18 @@ static CURLcode error_do_write(struct Curl_easy *data, struct Curl_cwriter *writer, int type, const char *buf, size_t nbytes) { - char all[256]; - (void)Curl_all_content_encodings(all, sizeof(all)); - (void) writer; (void) buf; (void) nbytes; if(!(type & CLIENTWRITE_BODY) || !nbytes) return Curl_cwriter_write(data, writer->next, type, buf, nbytes); - - failf(data, "Unrecognized content encoding type. " - "libcurl understands %s content encodings.", all); + else { + char all[256]; + (void)Curl_all_content_encodings(all, sizeof(all)); + failf(data, "Unrecognized content encoding type. " + "libcurl understands %s content encodings.", all); + } return CURLE_BAD_CONTENT_ENCODING; }