Skip to content

The null check for _var.c_str() results in a silent return, causing data to be dropped without any notification to the caller #517

@KostinPavel

Description

@KostinPavel

include/rfl/avro/Writer.hpp
Comment on lines +195 to +199
const char* cstr = _var.c_str();
if (!cstr) {
return;
}
avro_value_set_string_len(_val, cstr, _var.size() + 1);
@gemini-code-assist gemini-code-assist bot 2 hours ago
high

The null check for _var.c_str() results in a silent return, causing data to be dropped without any notification to the caller. This can lead to silent data loss, which can be very difficult to debug. The same issue exists for rfl::Bytestring and rfl::Vectorstring on lines 206-208.

Since this function is noexcept, you cannot throw an exception. Consider one of the following approaches:

Change the write pipeline to allow for error propagation (e.g., by removing noexcept and returning rfl::Result).
If noexcept is a hard requirement, have the Writer class maintain an error state that can be checked after the operation.
As a last resort, log the error before returning to make the silent failure observable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions