diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 474cdf96..b5cfccc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,3 +173,29 @@ jobs: # # ${PWD}/artifacts on the host. # run: | # ls -al "${PWD}/artifacts" + + build-santize-address: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: apt install + run: >- + sudo apt update && + sudo apt install libunwind-dev && + sudo apt install -y ${{ env.DEB_PKGS }} ${{ env.DEB_TEST_PKGS }} + - name: meson + run: | + meson --version + meson setup build -Dsanitize-address=true + env: + CXX: g++ + - name: build + run: ninja -v -C build + - name: install + run: sudo meson install -C build + - name: test + run: | + if ! xvfb-run -a meson test -C build --verbose --no-stdsplit; then + echo "::warning title=test-failed::test failed" + fi + continue-on-error: true diff --git a/meson.build b/meson.build index 19c5fe8e..303b7c70 100644 --- a/meson.build +++ b/meson.build @@ -3,6 +3,11 @@ project('iptux', 'cpp', version: '0.9.1', default_options: ['warning_level=3', 'cpp_std=c++14']) add_global_arguments('-Werror=format', language : 'cpp') +if get_option('sanitize-address') + add_project_arguments('-fsanitize=address', language: 'cpp') + add_project_link_arguments('-fsanitize=address', language: 'cpp') +endif + so_version = '0.9.1' subdir('src') subdir('share') diff --git a/meson_options.txt b/meson_options.txt index 3533d0ca..552c19ee 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -18,3 +18,10 @@ option( value: 'auto', description: 'enable app indicator support', ) + +option( + 'sanitize-address', + type: 'boolean', + value: 'false', + description: 'enable -fsanitize=address compile/link flag', +) diff --git a/src/iptux-core/internal/UdpDataServiceTest.cpp b/src/iptux-core/internal/UdpDataServiceTest.cpp index 7f57739a..6d77450e 100644 --- a/src/iptux-core/internal/UdpDataServiceTest.cpp +++ b/src/iptux-core/internal/UdpDataServiceTest.cpp @@ -1,5 +1,7 @@ #include "gtest/gtest.h" +#include + #include "iptux-core/TestHelper.h" #include "iptux-core/internal/UdpDataService.h" #include "iptux-utils/utils.h" @@ -9,13 +11,13 @@ using namespace iptux; TEST(UdpDataService, process) { auto core = newCoreThread(); - auto service = new UdpDataService(*core.get()); + auto service = make_unique(*core.get()); service->process(inAddrFromString("127.0.0.1"), 1234, "", 0, true); } TEST(UdpDataService, SomeoneEntry) { auto core = newCoreThread(); - auto service = new UdpDataService(*core.get()); + auto service = make_unique(*core.get()); const char* data = "iptux 0.8.0:1:lidaobing:lidaobing.lan:257:lidaobing"; service->process(inAddrFromString("127.0.0.1"), 1234, data, strlen(data), true); @@ -28,7 +30,7 @@ TEST(UdpDataService, CreatePalInfo) { "1_iptux " "0.8.0-b1:6:lidaobing:LIs-MacBook-Pro.local:259:中\xe4\xb8\x00\x00icon-" "tux.png\x00utf-8\x00"; - auto service = new UdpDataService(*core.get()); + auto service = make_unique(*core.get()); auto udp = service->process(inAddrFromString("127.0.0.1"), 1234, data, strlen(data), false); auto pal = udp->CreatePalInfo(); @@ -43,7 +45,7 @@ TEST(UdpDataService, CreatePalInfo) { "1_iptux " "0.8.0-b1:6:中\xe4\xb8:LIs-MacBook-Pro.local:259:" "中\xe4\xb8\x00\x00icon-tux.png\x00utf-8\x00"; - auto service = new UdpDataService(*core.get()); + auto service = make_unique(*core.get()); auto udp = service->process(inAddrFromString("127.0.0.1"), 1234, data, strlen(data), false); auto pal = udp->CreatePalInfo(); diff --git a/src/iptux/DataSettings.cpp b/src/iptux/DataSettings.cpp index 82b35874..842121ad 100644 --- a/src/iptux/DataSettings.cpp +++ b/src/iptux/DataSettings.cpp @@ -794,23 +794,24 @@ void DataSettings::ObtainPersonalValue() { snprintf(path, MAX_PATHLEN, "%d", active); gtk_tree_model_get_iter_from_string(model, &iter, path); gtk_tree_model_get(model, &iter, 1, &file, -1); - if (strcmp(g_progdt->myicon.c_str(), file) != 0) { - snprintf(path, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s", file); - if (access(path, F_OK) != 0) { - g_free(file); - g_progdt->myicon = "my-icon"; - snprintf(path, MAX_PATHLEN, "%s" ICON_PATH "/my-icon", - g_get_user_config_dir()); - gtk_tree_model_get(model, &iter, 0, &pixbuf, -1); - gdk_pixbuf_save(pixbuf, path, "png", NULL, NULL); - gtk_icon_theme_add_builtin_icon(g_progdt->myicon.c_str(), MAX_ICONSIZE, - pixbuf); - g_object_unref(pixbuf); - } else { - g_progdt->myicon = file; + if (file) { + if (strcmp(g_progdt->myicon.c_str(), file) != 0) { + snprintf(path, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s", file); + if (access(path, F_OK) != 0) { + g_progdt->myicon = "my-icon"; + snprintf(path, MAX_PATHLEN, "%s" ICON_PATH "/my-icon", + g_get_user_config_dir()); + gtk_tree_model_get(model, &iter, 0, &pixbuf, -1); + gdk_pixbuf_save(pixbuf, path, "png", NULL, NULL); + gtk_icon_theme_add_builtin_icon(g_progdt->myicon.c_str(), + MAX_ICONSIZE, pixbuf); + g_object_unref(pixbuf); + } else { + g_progdt->myicon = file; + } } - } else g_free(file); + } } widget = GTK_WIDGET(g_datalist_get_data(&widset, "archive-chooser-widget"));