From 536dc0cee40e494e9b40756b8fe9b48601b808ad Mon Sep 17 00:00:00 2001 From: HuangHaitao Date: Sat, 4 Jan 2025 14:31:30 +0800 Subject: [PATCH] Description:fix addr-sanitizer Signed-off-by: cavalier --- frameworks/js/napi/http/BUILD.gn | 5 +++++ frameworks/js/napi/http/http_exec/src/http_exec.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/frameworks/js/napi/http/BUILD.gn b/frameworks/js/napi/http/BUILD.gn index 69b99a836..f78519f37 100644 --- a/frameworks/js/napi/http/BUILD.gn +++ b/frameworks/js/napi/http/BUILD.gn @@ -172,6 +172,11 @@ ohos_shared_library("http") { external_deps += [ "init:libbegetutil" ] } } + + if (!is_mingw && !is_mac && current_os != "ios" && host_os != "mac" && + current_os != "mac" && current_os != "android") { + defines += [ "USE_ARES" ] + } include_dirs += [ "$NETSTACK_DIR/utils/profiler_utils/include", "$NETSTACK_DIR/utils/tlv_utils/include", diff --git a/frameworks/js/napi/http/http_exec/src/http_exec.cpp b/frameworks/js/napi/http/http_exec/src/http_exec.cpp index 7929fe646..f942dace9 100755 --- a/frameworks/js/napi/http/http_exec/src/http_exec.cpp +++ b/frameworks/js/napi/http/http_exec/src/http_exec.cpp @@ -315,7 +315,11 @@ bool HttpExec::RequestWithoutCache(RequestContext *context) } #endif +#ifdef USE_ARES + auto handle = curl_easy_init_with_cares(); +#else auto handle = curl_easy_init(); +#endif if (!handle) { NETSTACK_LOGE("Failed to create fetch task"); return false; -- Gitee