Don't append extra NUL to URLs in wxGTK wxURLDataObject

The buffer size includes the trailing NUL, but we shouldn't make it part
of the string contents as it's not really part of the data at all.

The next commit will add a test verifying that retrieving an URL from
clipboard now gets the right string, without an extra trailing NUL, i.e.
fixes a bug similar to #22928 but in wxGTK.
This commit is contained in:
Vadim Zeitlin 2022-12-06 01:53:06 +01:00
parent a577af1ca6
commit c93c346adc

View file

@ -438,6 +438,12 @@ public:
{
const char* const src = static_cast<const char*>(buf);
// Length here includes the trailing NUL, but we don't want to include
// it into the string contents.
wxCHECK_MSG( len != 0 && !src[len], false, "must have trailing NUL" );
len--;
// The string might be "\r\n"-terminated but this is not necessarily
// the case (e.g. when dragging an URL from Firefox, it isn't).
if ( len > 1 && src[len - 1] == '\n' )