File tree Expand file tree Collapse file tree 5 files changed +19
-6
lines changed
Expand file tree Collapse file tree 5 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ target_link_libraries(
99 PRIVATE infiz_options
1010 infiz_warnings
1111 libinfiz
12- -coverage
1312 -fsanitize=fuzzer)
1413target_compile_options (fuzz_tester PRIVATE -fsanitize=fuzzer)
1514
Original file line number Diff line number Diff line change 66// cppcheck-suppress unusedFunction symbolName=LLVMFuzzerTestOneInput
77extern " C" auto LLVMFuzzerTestOneInput (const std::uint8_t *Data, std::size_t Size) -> int
88{
9- [[maybe_unused]] const auto result = evaluate (std::string_view (reinterpret_cast <const char *>(Data), Size));// NOLINT
9+ try {
10+ [[maybe_unused]] const auto result =
11+ evaluate (std::string_view (reinterpret_cast <const char *>(Data), Size));// NOLINT
12+ } catch (const std::runtime_error &) {
13+ // malformed input, but not a memory error!
14+ }
1015 return 0 ;
1116}
Original file line number Diff line number Diff line change @@ -9,7 +9,12 @@ add_library(libinfiz
99
1010add_library (infiz::libinfiz ALIAS libinfiz)
1111
12- target_link_libraries (libinfiz PRIVATE infiz_options infiz_warnings)
12+ target_link_libraries (libinfiz PRIVATE infiz_options infiz_warnings -fsanitize=fuzzer-no -link)
13+
14+ if (infiz_BUILD_FUZZ_TESTS)
15+ target_link_libraries (libinfiz PRIVATE -fsanitize=fuzzer-no -link)
16+ target_compile_options (libinfiz PRIVATE -fsanitize=fuzzer-no -link)
17+ endif ()
1318
1419target_include_directories (libinfiz ${WARNING_GUARD} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include >
1520 $<BUILD_INTERFACE:${PROJECT_BINARY_DIR} /include >)
Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ class RationalNumber
1919 [[nodiscard]] constexpr auto simplify () const noexcept -> RationalNumber
2020 {
2121 const auto gcd = std::gcd (numerator, denominator);
22- return {numerator / gcd, denominator / gcd};
22+ if (gcd == 0 ) {
23+ return *this ;
24+ } else {
25+ return { numerator / gcd, denominator / gcd };
26+ }
2327 }
2428
2529 [[nodiscard]] constexpr auto operator /(const RationalNumber &rhs) const noexcept -> RationalNumber
Original file line number Diff line number Diff line change 66#include < cassert>
77#include < cstddef>
88#include < vector>
9+ #include < stdexcept>
910
1011/* *
1112 * A Class that allows allows void * to be
@@ -21,8 +22,7 @@ template<typename Contained> class Stack
2122
2223 auto pop () -> Contained
2324 {
24- // TODO is an assert the best option here?
25- assert (!data.empty ());
25+ if (data.empty ()) { throw std::runtime_error (" No elements left to pop!" ); }
2626 Contained toReturn = data.back ();
2727 data.pop_back ();
2828 return toReturn;
You can’t perform that action at this time.
0 commit comments