Added AddressSanitizer to debug builds

- Used ASAN to fix a small memleak in lpolllist.c (forgot to free hashmap)
This commit is contained in:
CPunch 2022-01-29 17:00:44 -06:00
parent 56c6db1d62
commit 773ea19532
2 changed files with 15 additions and 1 deletions

View File

@ -11,10 +11,23 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules" ${CMAKE_MODULE_PATH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
find_package(Sanitizers)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Release)
endif()
string(TOLOWER ${CMAKE_BUILD_TYPE} RAWCMAKEBUILDTYPE)
message(STATUS "CMAKE_BUILD_TYPE: " ${RAWCMAKEBUILDTYPE})
if(RAWCMAKEBUILDTYPE STREQUAL "debug")
message(STATUS "Adding sanitizer...")
add_sanitizers(LaikaLib LaikaBot LaikaCNC)
# bug in FindSanitizer.cmake ??? idfk, i'll investigate l8tr
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif ()
# compile laikalib, tools, cnc & bot
add_subdirectory(lib)
add_subdirectory(tools)

View File

@ -43,6 +43,7 @@ void laikaP_initPList(struct sLaika_pollList *pList) {
void laikaP_cleanPList(struct sLaika_pollList *pList) {
laikaM_free(pList->revents);
hashmap_free(pList->sockets);
#ifdef LAIKA_USE_EPOLL
close(pList->epollfd);