Skip to content

Conversation

@kostiantynperehuda
Copy link
Contributor

Constructing a std::string from a nullptr is undefined behavior and has been removed in C++23.

This fix ensures well-defined behavior and allows the project to build successfully when using the C++23 standard.

Constructing a string from a nullptr is an undefined behavior and is
disallowed in c++23
@yogeshbdeshpande
Copy link

yogeshbdeshpande commented Oct 22, 2025

Please note that the ADOBE CLA was signed from Arm as an organisation so this contribution needs to proceed.

Also, request add suitable reviewer to the PR and please provide review comments and approve.

Thanks for all help.

If any questions: Please contact [email protected]

@yogeshbdeshpande
Copy link

@gpeacock : Please add suitable reviewers!

@tmathern
Copy link
Collaborator

tmathern commented Nov 4, 2025

Added @gpeacock and @dyro as reviewers.

Signer(C2paSigner *signer) : signer(signer) {}

Signer(const string &alg, const string &sign_cert, const string&private_key, const string &tsa_uri = NULL);
Signer(const string &alg, const string &sign_cert, const string&private_key, const string &tsa_uri = {});
Copy link
Collaborator

@dyro dyro Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to change this to the following, if we are going to make a change to the API:

Header

Signer::Signer(const string &alg, const string &sign_cert, const string &private_key, optional<std::string> tsa_uri)

Implementation

// implementation then would be something like this:
Signer::Signer(const string &alg, const string &sign_cert, const string &private_key,
               optional<std::string> tsa_uri) {
    auto info = C2paSignerInfo{
        alg.c_str(),
        sign_cert.c_str(),
        private_key.c_str(),
        tsa_uri.has_value() ? tsa_uri->c_str() : nullptr
    };
    signer = c2pa_signer_from_info(&info);
}

Since we are already changing the API, let's make it more semantically correct. Also, using a string as the default changes the behavior of the API. Using a zero length string would mean we are passing a non-nullptr to the Rust code, which may change the behavior of the rust sdk. Lemme know what you think!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already include in the headers and use it in other apis, so this is the right approach here.
FYI, we are a little inconsistent, usually just referring to optional instead of std:optional in the source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants