Ignore NULL headers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/src/transports/http.c b/src/transports/http.c
index 764c6a9..73ea050 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -213,7 +213,8 @@ static int gen_request(
if (t->owner->custom_headers) {
for (i = 0; i < t->owner->custom_headers->count; i++) {
- git_buf_printf(buf, "%s\r\n", t->owner->custom_headers->strings[i]);
+ if (t->owner->custom_headers->strings[i])
+ git_buf_printf(buf, "%s\r\n", t->owner->custom_headers->strings[i]);
}
}
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index 8e2bdd4..5b00d90 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -412,17 +412,19 @@ static int winhttp_stream_connect(winhttp_stream *s)
if (t->owner->custom_headers) {
for (i = 0; i < t->owner->custom_headers->count; i++) {
- git_buf_clear(&buf);
- git_buf_puts(&buf, t->owner->custom_headers->strings[i]);
- if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) {
- giterr_set(GITERR_OS, "Failed to convert custom header to wide characters");
- goto on_error;
- }
+ if (t->owner->custom_headers->strings[i]) {
+ git_buf_clear(&buf);
+ git_buf_puts(&buf, t->owner->custom_headers->strings[i]);
+ if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) {
+ giterr_set(GITERR_OS, "Failed to convert custom header to wide characters");
+ goto on_error;
+ }
- if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L,
- WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) {
- giterr_set(GITERR_OS, "Failed to add a header to the request");
- goto on_error;
+ if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L,
+ WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) {
+ giterr_set(GITERR_OS, "Failed to add a header to the request");
+ goto on_error;
+ }
}
}
}