Skip to content

Commit 0d84ecb

Browse files
authored
Prevent exceptions of unintended type from escaping from parser (#407)
1 parent 0177c8f commit 0d84ecb

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

private/rdf4cpp/parser/IStreamQuadIteratorSerdImpl.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ nonstd::expected<Node, SerdStatus> IStreamQuadIterator::Impl::get_bnode(std::str
5151
.col = serd_reader_get_current_col(this->reader),
5252
.message = std::string{e.what()} + ". note: position may not be accurate and instead point to the end of the triple."};
5353

54+
return nonstd::make_unexpected(SERD_ERR_BAD_SYNTAX);
55+
} catch (...) {
56+
this->last_error = ParsingError{.error_type = ParsingError::Type::BadBlankNode,
57+
.line = serd_reader_get_current_line(this->reader),
58+
.col = serd_reader_get_current_col(this->reader),
59+
.message = "Unknown internal error. note: position may not be accurate and instead point to the end of the triple."};
60+
5461
return nonstd::make_unexpected(SERD_ERR_BAD_SYNTAX);
5562
}
5663
}
@@ -160,6 +167,13 @@ nonstd::expected<Literal, SerdStatus> IStreamQuadIterator::Impl::get_literal(Ser
160167
.col = serd_reader_get_current_col(this->reader),
161168
.message = std::string{e.what()} + ". note: position may not be accurate and instead point to the end of the triple."};
162169

170+
return nonstd::make_unexpected(SERD_ERR_BAD_SYNTAX);
171+
} catch (...) {
172+
this->last_error = ParsingError{.error_type = ParsingError::Type::BadLiteral,
173+
.line = serd_reader_get_current_line(this->reader),
174+
.col = serd_reader_get_current_col(this->reader),
175+
.message = "Unknown internal error. note: position may not be accurate and instead point to the end of the triple."};
176+
163177
return nonstd::make_unexpected(SERD_ERR_BAD_SYNTAX);
164178
}
165179
}

0 commit comments

Comments
 (0)