|  | @@ -234,6 +234,9 @@ static void DEBUG_TRACE_FUNC(const char *func,
 | 
	
		
			
				|  |  |  	DEBUG_TRACE_FUNC(__func__, __LINE__, fmt, __VA_ARGS__)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #define NEED_DEBUG_TRACE_FUNC
 | 
	
		
			
				|  |  | +#ifndef DEBUG_TRACE_STREAM
 | 
	
		
			
				|  |  | +# define DEBUG_TRACE_STREAM   stdout
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  |  #define DEBUG_TRACE(fmt, ...)                                                  \
 | 
	
	
		
			
				|  | @@ -1743,8 +1746,8 @@ DEBUG_TRACE_FUNC(const char *func, unsigned line, const char *fmt, ...)
 | 
	
		
			
				|  |  |  		nslast = nsnow;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	flockfile(stdout);
 | 
	
		
			
				|  |  | -	printf("*** %lu.%09lu %12" INT64_FMT " %lu %s:%u: ",
 | 
	
		
			
				|  |  | +	flockfile(DEBUG_TRACE_STREAM);
 | 
	
		
			
				|  |  | +	fprintf( DEBUG_TRACE_STREAM,"*** %lu.%09lu %12" INT64_FMT " %lu %s:%u: ",
 | 
	
		
			
				|  |  |  	       (unsigned long)tsnow.tv_sec,
 | 
	
		
			
				|  |  |  	       (unsigned long)tsnow.tv_nsec,
 | 
	
		
			
				|  |  |  	       nsnow - nslast,
 | 
	
	
		
			
				|  | @@ -1752,11 +1755,11 @@ DEBUG_TRACE_FUNC(const char *func, unsigned line, const char *fmt, ...)
 | 
	
		
			
				|  |  |  	       func,
 | 
	
		
			
				|  |  |  	       line);
 | 
	
		
			
				|  |  |  	va_start(args, fmt);
 | 
	
		
			
				|  |  | -	vprintf(fmt, args);
 | 
	
		
			
				|  |  | +	vfprintf(DEBUG_TRACE_STREAM, fmt, args);
 | 
	
		
			
				|  |  |  	va_end(args);
 | 
	
		
			
				|  |  | -	putchar('\n');
 | 
	
		
			
				|  |  | -	fflush(stdout);
 | 
	
		
			
				|  |  | -	funlockfile(stdout);
 | 
	
		
			
				|  |  | +	putc('\n', DEBUG_TRACE_STREAM);
 | 
	
		
			
				|  |  | +	fflush(DEBUG_TRACE_STREAM);
 | 
	
		
			
				|  |  | +	funlockfile(DEBUG_TRACE_STREAM);
 | 
	
		
			
				|  |  |  	nslast = nsnow;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  #endif /* NEED_DEBUG_TRACE_FUNC */
 | 
	
	
		
			
				|  | @@ -1810,6 +1813,9 @@ typedef struct SSL_CTX SSL_CTX;
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * #define OPENSSL_free free */
 | 
	
		
			
				|  |  |  #define free free
 | 
	
		
			
				|  |  | +// disable for boringssl
 | 
	
		
			
				|  |  | +#define CONF_modules_unload(a) ((void)0)
 | 
	
		
			
				|  |  | +#define ENGINE_cleanup() ((void)0)
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
 | 
	
	
		
			
				|  | @@ -9556,7 +9562,7 @@ static void *
 | 
	
		
			
				|  |  |  realloc2(void *ptr, size_t size)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |  	void *new_ptr = mg_realloc(ptr, size);
 | 
	
		
			
				|  |  | -	if (new_ptr == NULL) {
 | 
	
		
			
				|  |  | +	if ((new_ptr == NULL) && (size > 0)) {
 | 
	
		
			
				|  |  |  		mg_free(ptr);
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	return new_ptr;
 | 
	
	
		
			
				|  | @@ -17096,8 +17102,8 @@ mg_connect_client2(const char *host,
 | 
	
		
			
				|  |  |  	opts.port = port;
 | 
	
		
			
				|  |  |  	return mg_connect_client_impl(&opts,
 | 
	
		
			
				|  |  |  	                              is_ssl,
 | 
	
		
			
				|  |  | -	                              error->text,
 | 
	
		
			
				|  |  | -	                              error->text_buffer_size);
 | 
	
		
			
				|  |  | +	                              ((error != NULL) ? error->text : NULL),
 | 
	
		
			
				|  |  | +	                              ((error != NULL) ? error->text_buffer_size : 0));
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -19711,6 +19717,7 @@ mg_start_domain2(struct mg_context *ctx,
 | 
	
		
			
				|  |  |  				            config_options[AUTHENTICATION_DOMAIN].name);
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			mg_free(new_dom);
 | 
	
		
			
				|  |  | +			mg_unlock_context(ctx);
 | 
	
		
			
				|  |  |  			return -5;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 |