From daa8d4a1464598c6bf163a526c95227a6dd29659 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 1 May 2026 06:38:32 +0300 Subject: [PATCH] cgen: sanitized test fix --- vlib/net/http/http_proxy_test.v | 3 +++ vlib/v/gen/c/struct.v | 2 +- vlib/v/gen/c/testdata/heap_struct_init.c.must_have | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/vlib/net/http/http_proxy_test.v b/vlib/net/http/http_proxy_test.v index 349491a32..9c9608295 100644 --- a/vlib/net/http/http_proxy_test.v +++ b/vlib/net/http/http_proxy_test.v @@ -197,6 +197,9 @@ fn test_https_proxy_requests_do_not_leak_sockets() ! { $if windows { return } + $if sanitized_job ? { + return + } target_port, target_done := start_https_proxy_test_target_server()! proxy_port, proxy_done := start_https_proxy_test_server(target_port)! baseline_fds := count_open_file_descriptors() diff --git a/vlib/v/gen/c/struct.v b/vlib/v/gen/c/struct.v index 038469215..8f67cd699 100644 --- a/vlib/v/gen/c/struct.v +++ b/vlib/v/gen/c/struct.v @@ -586,7 +586,7 @@ fn (mut g Gen) direct_heap_struct_init(node ast.StructInit, styp string, info as if info.is_empty_struct() { g.writeln('${styp}* ${tmp_var} = HEAP(${styp}, ((${styp}){E_STRUCT}));') } else { - g.writeln('${styp}* ${tmp_var} = (${styp}*)builtin___v_malloc(sizeof(${styp}));') + g.writeln('${styp}* ${tmp_var} = (${styp}*)builtin___v_malloc(sizeof(${styp}) == 0 ? 1 : sizeof(${styp}));') } for i, init_field in node.init_fields { mut resolved_field := init_field diff --git a/vlib/v/gen/c/testdata/heap_struct_init.c.must_have b/vlib/v/gen/c/testdata/heap_struct_init.c.must_have index c9eabfd04..844a4a5a8 100644 --- a/vlib/v/gen/c/testdata/heap_struct_init.c.must_have +++ b/vlib/v/gen/c/testdata/heap_struct_init.c.must_have @@ -1,3 +1,3 @@ -builtin___v_malloc(sizeof(main__Foo)); +builtin___v_malloc(sizeof(main__Foo) == 0 ? 1 : sizeof(main__Foo)); ->x = _S("x"); ->y = _S("y"); -- 2.39.5