String alloc shouldn't convert to std::string.
Some checks failed
CI / ubuntu-latest-html-tests (push) Has been cancelled
CI / alpine-mbedtls-3_6_0 (push) Has been cancelled
CI / ubuntu-latest-no-tls (push) Has been cancelled
CI / ubuntu-latest-mbedtls2 (push) Has been cancelled
CI / ubuntu-latest-openssl-3 (push) Has been cancelled
CI / ubuntu-latest-with-old-std (push) Has been cancelled
CI / ubuntu-20-04-openssl-1-1 (push) Has been cancelled
CI / macOS-13-openssl-1-1 (push) Has been cancelled
CI / macOS-13-openssl-3 (push) Has been cancelled
CI / freebsd-14-openssl-3 (push) Has been cancelled
CI / windows-mbedtls (push) Has been cancelled

As I work through making code use more C++ RAII and such, most
of the work is handling strings, especially temporaries.  As member
variables which manage string memory get turned into `std::string`,
some use cases might wind up leaking memory.  (One was found in
this change.)

By using a non-convertible-to-string result, such accidents should
be avoided.
This commit is contained in:
2025-09-08 13:24:56 -04:00
parent 97baa28f57
commit 1bf12c858f
8 changed files with 29 additions and 22 deletions

View File

@ -861,7 +861,7 @@ void Html_tag_open_option(DilloHtml *html, const char *tag, int tagsize)
bool enabled = (a_Html_get_attr(html, tag, tagsize, "disabled") == NULL);
auto option =
std::make_unique< DilloHtmlOption >(value ? dStrdup( value.value().c_str() ) : nullptr, label ? dStrdup( label.value().c_str() ) : nullptr, selected, enabled );
std::make_unique< DilloHtmlOption >(value ? dStrdup( value.value().c_str() ).ptr : nullptr, label ? dStrdup( label.value().c_str() ).ptr : nullptr, selected, enabled );
input->select->addOpt( std::move( option ) );
}