-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pasting non-text input crashes Minetest #14150
Comments
Can't reproduce on linux with SDL2 irrlicht device. |
I achieved a similar result, although I am not certain if I can reproduce it the exact same way I did it. |
@rewired-X can you post the details of your OS and build? ( |
I can confirm this issue on Windows 10 (10.0.19045). This issue does not occur in 5.7.0 or older. |
This issue is caused by minetest/irrlicht#249 (specifically minetest/irrlicht@c766c3a). Stack trace: /* 7 */ irr::core::wStringToUTF8(class irr::core::string<char> &,wchar_t const *)
/* 6 */ irr::COSOperator::getTextFromClipboard(void)
/* 5 */ irr::gui::CGUIEditBox::processKey(struct irr::SEvent const &)
/* 4 */ irr::gui::CGUIEditBox::OnEvent(struct irr::SEvent const &)
/* 3 */ irr::gui::CGUIEnvironment::postEventFromUser(struct irr::SEvent const &)
/* 2 */ irr::CIrrDeviceStub::postEventFromUser(struct irr::SEvent const &)
/* 1 */ WndProc(struct HWND__ *,unsigned int,unsigned __int64,__int64) Possible fix: diff --git a/source/Irrlicht/COSOperator.cpp b/source/Irrlicht/COSOperator.cpp
index d2b3b8d..33b07ec 100644
--- a/source/Irrlicht/COSOperator.cpp
+++ b/source/Irrlicht/COSOperator.cpp
@@ -162,6 +162,9 @@ const c8* COSOperator::getTextFromClipboard() const
wchar_t * buffer = 0;
HANDLE hData = GetClipboardData( CF_UNICODETEXT );
+ if (hData == NULL) // Probably not in Unicode text format
+ return 0;
+
buffer = (wchar_t*) GlobalLock( hData );
core::wStringToUTF8(ClipboardBuf, buffer); |
So this doesn't happen with (Also, I'm wondering why the missing null check didn't cause problems before minetest/irrlicht@c766c3a.) |
Yes, this issue does not occur using SDL2.
My guess is that the old code checks for null-ness of static inline size_t wStringToMultibyte(string<c8>& destination, const wchar_t* source)
{
const u32 s = source ? (u32)wcslen(source) : 0;
return wStringToMultibyte(destination, source, s);
} static size_t wStringToMultibyte(string<c8>& destination, const wchar_t* source, u32 sourceSize)
{
if ( sourceSize )
{
// ...
}
else
{
destination.clear();
return 0;
}
} |
@fluxionary live from the windows command prompt :P |
Alright, do you want to open a PR? |
I am planning to do it. |
Minetest version
Active renderer
OpenGL 4.6
Irrlicht device
No response
Operating system and version
Windows 11
CPU model
No response
GPU model
No response
OpenGL version
4.6
Summary
When trying to paste something that is not text (e.g. a file) into a formspec using Crtl + C and Ctrl + V Minetest will crash with no errors in the logs.
Steps to reproduce
Copy any file with Ctrl + C. Try to paste it into a formspec, e.g. a sign input field, with Ctrl + V.
The text was updated successfully, but these errors were encountered: