diff --git a/cmake/OS_Detection.cmake b/cmake/OS_Detection.cmake index 51bc3a0bc7b07c5f5710d910ad761ac11ea6b431..29ba720c909c61c35b2c365caf475ce52cca3db1 100644 --- a/cmake/OS_Detection.cmake +++ b/cmake/OS_Detection.cmake @@ -104,8 +104,22 @@ if(UNIX) set(_LOPT "-pg") if (DEFINED ENV{DAP_ASAN}) message("[!] Address Sanitizer enabled") - set(_CCOPT "${_CCOPT} -fsanitize=address -fno-omit-frame-pointer -fno-common -O1") + set(_CCOPT "${_CCOPT} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -fno-common -O1") set(_LOPT "${_LOPT} -fsanitize=address") + elseif(DEFINED ENV{DAP_MSAN}) + if (CMAKE_C_COMPILER_ID MATCHES ".*[Cc][Ll][Aa][Nn][Gg].*") + message("[!] Memory Sanitizer enabled") + set(_CCOPT "${_CCOPT} -fsanitize=memory -fPIE -pie -fno-omit-frame-pointer -O2") + set(_LOPT "${_LOPT} -fsanitize=memory -fPIE -pie") + else() + message("[!] Memory Sanitizer is not available on this compiler") + endif() + elseif(DEFINED ENV{DAP_TSAN}) + message("[!] Thread Sanitizer enabled") + set(_CCOPT "${_CCOPT} -fsanitize=thread") + set(_LOPT "${_LOPT} -fsanitize=thread") + elseif(DEFINED ENV{DAP_UBSAN}) + message("[!] Undefined behaviour Sanitizer enabled") endif() SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") else() diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index 960a8009d99ead3e325976215ad538b7c4300b54..6cf79190c0af2db8a537806d3ecaf090482d779c 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -3530,7 +3530,7 @@ static int s_parse_additional_token_decl_arg(int a_argc, char ** a_argv, char ** } size_t l_tsd_offset = 0; a_params->ext.parsed_tsd = DAP_NEW_SIZE(byte_t, l_tsd_total_size); - if(!a_params->ext.parsed_tsd) { + if(l_tsd_total_size && !a_params->ext.parsed_tsd) { log_it(L_CRITICAL, "Memory allocation error"); return -1; }