Skip to content

Commit 644e35a

Browse files
committed
Implement sanitizer builds, update Makefile patch, and add issue #261 reference
1 parent 79f3c33 commit 644e35a

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
env:
1515
CC: ${{matrix.cc}}
1616
CXX: ${{matrix.cxx}}
17+
CXXFLAGS: ${{matrix.env_cxxflags}}
18+
LDFLAGS: ${{matrix.env_ldflags}}
1719
defaults:
1820
run:
1921
shell: bash
@@ -51,13 +53,15 @@ jobs:
5153
cxx: clang++-19
5254
os: ubuntu-latest
5355
container: ubuntu:24.04
54-
build_options: "CXXFLAGS='-fsanitize=address,undefined -g' LDFLAGS='-fsanitize=address,undefined'"
56+
env_cxxflags: "-fsanitize=address,undefined"
57+
env_ldflags: "-fsanitize=address,undefined"
5558

5659
- name: clang-sanitizer-macOS
5760
cc: clang
5861
cxx: clang++
5962
os: macos-latest
60-
build_options: "CXXFLAGS='-fsanitize=address,undefined -g' LDFLAGS='-fsanitize=address,undefined'"
63+
env_cxxflags: "-fsanitize=address,undefined"
64+
env_ldflags: "-fsanitize=address,undefined"
6165

6266
steps:
6367
- name: Checkout

‎Makefile‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ GMAKE = make mode=$(mode)
3636
NAME := sqlparser
3737
PARSER_CPP = $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
3838
PARSER_H = $(SRCPARSER)/bison_parser.h $(SRCPARSER)/flex_lexer.h
39-
LIB_CFLAGS = -std=c++17 $(OPT_FLAG)
39+
LIB_CFLAGS = -std=c++17 $(OPT_FLAG) $(CXXFLAGS)
40+
LIB_LFLAGS = $(LDFLAGS)
41+
4042

4143
relaxed_build ?= "off"
4244
ifeq ($(relaxed_build), on)
@@ -54,12 +56,12 @@ static ?= no
5456
ifeq ($(static), yes)
5557
LIB_BUILD = lib$(NAME).a
5658
LIBLINKER = $(AR)
57-
LIB_LFLAGS = rs
59+
LIB_LFLAGS += rs
5860
else
5961
LIB_BUILD = lib$(NAME).so
6062
LIBLINKER = $(CXX)
6163
LIB_CFLAGS += -fPIC
62-
LIB_LFLAGS = -shared -o
64+
LIB_LFLAGS += -shared -o
6365
endif
6466
LIB_CPP = $(sort $(shell find $(SRC) -name '*.cpp' -not -path "$(SRCPARSER)/*") $(PARSER_CPP))
6567
LIB_H = $(shell find $(SRC) -name '*.h' -not -path "$(SRCPARSER)/*") $(PARSER_H)

‎test/sql_parser.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ TEST(SQLParserTokenizeStringifyTest) {
4343
ASSERT(&query != &cache[token_string]);
4444
}
4545

46+
// Regression test for the memory leak reported in issue #261.
4647
TEST(SQLParserTokenizeLeakRegressionTest) {
4748

4849
const std::string query = "'string_1' 'string_2' 'string_3';";
@@ -55,4 +56,4 @@ TEST(SQLParserTokenizeLeakRegressionTest) {
5556
ASSERT_EQ(tokens[1], SQL_STRING);
5657
ASSERT_EQ(tokens[2], SQL_STRING);
5758
ASSERT_EQ(tokens[3], ';');
58-
}
59+
}

0 commit comments

Comments
 (0)