martinzink commented on code in PR #1885:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1885#discussion_r1822764157
##########
extensions/kafka/PublishKafka.cpp:
##########
@@ -164,49 +146,36 @@ class PublishKafka::Messages {
namespace {
class ReadCallback {
- public:
- struct rd_kafka_headers_deleter {
- void operator()(rd_kafka_headers_t* ptr) const noexcept {
- rd_kafka_headers_destroy(ptr);
- }
- };
-
- using rd_kafka_headers_unique_ptr = std::unique_ptr<rd_kafka_headers_t,
rd_kafka_headers_deleter>;
-
- private:
void allocate_message_object(const size_t segment_num) const {
messages_->modifyResult(flow_file_index_, [segment_num](FlowFileResult&
flow_file) {
// allocate message object to be filled in by the callback in produce()
- if (flow_file.messages.size() < segment_num + 1) {
- flow_file.messages.resize(segment_num + 1);
- }
+ if (flow_file.messages.size() < segment_num + 1) {
flow_file.messages.resize(segment_num + 1); }
gsl_Ensures(flow_file.messages.size() > segment_num);
});
}
- static rd_kafka_headers_unique_ptr make_headers(const core::FlowFile&
flow_file, const std::optional<utils::Regex>& attribute_name_regex) {
- const gsl::owner<rd_kafka_headers_t*> result{ rd_kafka_headers_new(8) };
- if (!result) { throw std::bad_alloc{}; }
Review Comment:
I've readded it in [readd nullcheck after
malloc](https://github.com/apache/nifi-minifi-cpp/pull/1885/commits/030d1635059825c3906a80c3a6f6b9eb81692652)
although I don't think we check every malloc/new in the codebase, but it
couldnt hurt either
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]