Skip to content

Commit

Permalink
feat: enable address and leak detection on all debug builds (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
EpsilonPrime committed Aug 16, 2023
1 parent 0a71a2f commit e53dd8b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_compile_options($<$<CONFIG:Debug>:-fsanitize=undefined>)
add_link_options($<$<CONFIG:Debug>:-fsanitize=undefined>)

add_compile_options($<$<CONFIG:Debug>:-fsanitize=address>)
add_link_options($<$<CONFIG:Debug>:-fsanitize=address>)

option(
SUBSTRAIT_CPP_BUILD_TESTING
"Enable substrait-cpp tests. This will enable all other build options automatically."
Expand Down
6 changes: 5 additions & 1 deletion src/substrait/textplan/parser/SubstraitPlanTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,15 @@ ::substrait::proto::Type SubstraitPlanTypeVisitor::typeToProto(
}
case TypeKind::kVarchar: {
auto varChar =
reinterpret_cast<const ParameterizedFixedChar*>(&decodedType);
reinterpret_cast<const ParameterizedVarchar*>(&decodedType);
if (varChar == nullptr) {
break;
}
try {
if (!varChar->length()->isInteger()) {
errorListener_->addError(ctx->getStart(), "Missing varchar length.");
break;
}
int32_t length = std::stoi(varChar->length()->value());
type.mutable_varchar()->set_length(length);
} catch (...) {
Expand Down
7 changes: 6 additions & 1 deletion src/substrait/type/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ ParameterizedTypePtr ParameterizedType::decode(

const auto& leftAngleBracketPos = matchingType.find('<');
if (leftAngleBracketPos == std::string::npos) {
bool nullable = matchingType.back() == '?';
bool nullable;
if (matchingType.empty()) {
nullable = false;
} else {
nullable = matchingType.back() == '?';
}
// deal with type and with a question mask like "i32?".
const auto& baseType = nullable
? matchingType = matchingType.substr(0, questionMaskPos)
Expand Down

0 comments on commit e53dd8b

Please sign in to comment.