From 9e09b709e35a00f81279bc231821bb05a42c5302 Mon Sep 17 00:00:00 2001 From: Isaiah <16439221+IsaiahPatton@users.noreply.github.com> Date: Tue, 10 May 2022 07:00:55 -0400 Subject: [PATCH] net.http: fix crash on Windows when using Boehm GC (#14351) --- thirdparty/vschannel/vschannel.c | 2 +- thirdparty/vschannel/vschannel.h | 4 ++++ vlib/net/http/backend_windows.c.v | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/thirdparty/vschannel/vschannel.c b/thirdparty/vschannel/vschannel.c index 0d55dde7e8..51d4e61a68 100644 --- a/thirdparty/vschannel/vschannel.c +++ b/thirdparty/vschannel/vschannel.c @@ -877,7 +877,7 @@ static SECURITY_STATUS https_make_request(TlsContext *tls_ctx, CHAR *req, CHAR * // increase buffer size if we need int required_length = *length+(int)pDataBuffer->cbBuffer; if( required_length > buff_size ) { - CHAR *a = realloc(*out, required_length); + CHAR *a = VSCHANNEL_REALLOC(*out, required_length); if( a == NULL ) { scRet = SEC_E_INTERNAL_ERROR; return scRet; diff --git a/thirdparty/vschannel/vschannel.h b/thirdparty/vschannel/vschannel.h index 0338645c58..2587ef1a1c 100644 --- a/thirdparty/vschannel/vschannel.h +++ b/thirdparty/vschannel/vschannel.h @@ -20,6 +20,10 @@ // Define here to be sure #define SP_PROT_TLS1_2_CLIENT 0x00000800 +#if !defined(VSCHANNEL_REALLOC) +#define VSCHANNEL_REALLOC realloc +#endif + typedef struct TlsContext TlsContext; TlsContext new_tls_context(); diff --git a/vlib/net/http/backend_windows.c.v b/vlib/net/http/backend_windows.c.v index 49de426187..51f6a35582 100644 --- a/vlib/net/http/backend_windows.c.v +++ b/vlib/net/http/backend_windows.c.v @@ -3,6 +3,10 @@ // that can be found in the LICENSE file. module http +$if gcboehm ? { + #define VSCHANNEL_REALLOC GC_REALLOC +} + #flag windows -I @VEXEROOT/thirdparty/vschannel #flag -l ws2_32 -l crypt32 -l secur32 -l user32 #include "vschannel.c"