Skip to content

Commit 02046d7

Browse files
Attempt at leak
1 parent 3527d87 commit 02046d7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

remote-curl.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,26 @@ static struct discovery *discover_refs(const char *service, int for_push)
540540
show_http_message_fatal(&type, &charset, &buffer,
541541
_("unable to access '%s' with http.pinnedPubkey configuration: %s"),
542542
transport_anonymize_url(url.buf), curl_errorstr);
543-
case HTTP_RATE_LIMITED:
543+
case HTTP_RATE_LIMITED: {
544+
/*
545+
* For HTTP_RATE_LIMITED (retry case), we need to handle
546+
* reencoding and free the reencoded buffer ourselves.
547+
*/
548+
char *saved_charset_buf = NULL;
549+
if (charset.len && !strcmp(type.buf, "text/plain")) {
550+
saved_charset_buf = xstrdup(charset.buf);
551+
if (strbuf_reencode(&buffer, saved_charset_buf, get_log_output_encoding()) == 0) {
552+
/* Reencoding succeeded, buffer now contains reencoded data */
553+
/* Clear charset so show_http_message_fatal doesn't reencode again */
554+
strbuf_reset(&charset);
555+
}
556+
free(saved_charset_buf);
557+
}
544558
show_http_message_fatal(&type, &charset, &buffer,
545559
_("rate limited by '%s', please try again later"),
546560
transport_anonymize_url(url.buf));
561+
break;
562+
}
547563
default:
548564
show_http_message_fatal(&type, &charset, &buffer,
549565
_("unable to access '%s': %s"),

0 commit comments

Comments
 (0)