Skip to content

Commit 226eec9

Browse files
committed
misc: fix untouched UB + add macos to cmake (forgort)
why the fuck until now it wasn't UB?? now I gotta add -fsanitize=address to my debug builds
1 parent df9cf5c commit 226eec9

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ file(GLOB
1414
"src/*.cpp"
1515
"src/query/linux/*.cpp"
1616
"src/query/android/*.cpp"
17+
"src/query/macos/*.cpp"
1718
"src/query/linux/utils/*.cpp"
1819
"src/toml++/toml.cpp")
1920

2021
if(GUI_APP)
21-
set(TARGET_NAME customfetch-gui)
22+
set(TARGET_NAME customfetch-gui)
2223
else()
23-
set(TARGET_NAME customfetch)
24+
set(TARGET_NAME customfetch)
2425
endif()
2526

2627
add_executable(${TARGET_NAME} ${SRC})

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ USE_DCONF ?= 1
1616
# WAY easier way to build debug and release builds
1717
ifeq ($(DEBUG), 1)
1818
BUILDDIR = build/debug
19-
CXXFLAGS := -ggdb3 -Wall -Wextra -Wpedantic -Wno-unused-parameter -DDEBUG=1 $(DEBUG_CXXFLAGS) $(CXXFLAGS)
19+
CXXFLAGS := -ggdb3 -Wall -Wextra -Wpedantic -Wno-unused-parameter -DDEBUG=1 -fsanitize=address $(DEBUG_CXXFLAGS) $(CXXFLAGS)
20+
LDFLAGS += -fsanitize=address
2021
else
2122
# Check if an optimization flag is not already set
2223
ifneq ($(filter -O%,$(CXXFLAGS)),)

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ static bool parseargs(int argc, char* argv[], Config& config, const std::string_
605605
case 'N':
606606
config.args_disable_colors = true; break;
607607
case 'a':
608-
config.overrides["config.ascii-logo-type"] = {.value_type = STR, .string_value = optarg};
608+
config.overrides["config.ascii-logo-type"] = {.value_type = STR, .string_value = optarg}; break;
609609
case 'n':
610610
config.args_disable_source = true; break;
611611
case 'L':

src/parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ std::string get_and_color_percentage(const float n1, const float n2, parse_args_
222222
color = "${" + config.percentage_colors.at(2) + "}";
223223
}
224224
else
225-
{
225+
{
226226
if (result <= 45)
227227
color = "${" + config.percentage_colors.at(2) + "}";
228228
else if (result <= 80)

src/query/linux/theme.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static bool get_xsettings_xfce4(const std::string_view property, const std::stri
5050
{
5151
static bool done = false;
5252
static rapidxml::xml_document<> doc;
53+
static std::string buffer;
5354

5455
if (!done)
5556
{
@@ -58,7 +59,7 @@ static bool get_xsettings_xfce4(const std::string_view property, const std::stri
5859
if (!f.is_open())
5960
return false;
6061

61-
std::string buffer((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
62+
buffer.assign(std::istreambuf_iterator<char>{f}, std::istreambuf_iterator<char>());
6263
buffer.push_back('\0');
6364

6465
doc.parse<0>(&buffer[0]);

0 commit comments

Comments
 (0)