Using an unsupported CursorType causes a crash
Marioalexsan opened this issue · comments
The following code causes a segmentation fault on Debian 12. This is due to CSFML's sfCursor_createFromSystem
returning a null pointer for unsupported cursors, and C#'s cursor taking that pointer and using it as-is.
using SFML.Window;
namespace SFMLRepro;
public static class Program
{
public static void Main(string[] args)
{
using var window = new Window(new VideoMode(1280, 720), "SFML Cursor Crash");
var cursorType = Cursor.CursorType.ArrowWait;
using var cursor = new Cursor(cursorType);
window.SetMouseCursor(cursor);
}
}
I'd expect there to be an exception explaining the issue instead of the application hard crashing from this, since the C++ lib returns booleans to communicate success or failure of the operation. I think there's other places in the code that might have a similar issue (like the other constructor that calls sfCursor_createFromPixels
and also takes the pointer as-is).