Fixes a crash on file picker cancel.
@@ -58,9 +58,12 @@ namespace StereoKit
static PickerCallback _filePickerCallback;
private static void FilePickerCallback(IntPtr data, int confirmed, IntPtr file, int fileLength)
{
+ string filename = "";
+ if (file != IntPtr.Zero) {
byte[] filenameUtf8 = new byte[fileLength];
Marshal.Copy(file, filenameUtf8, 0, fileLength);
- string filename = Encoding.UTF8.GetString(filenameUtf8);
+ filename = Encoding.UTF8.GetString(filenameUtf8);
+ }
if (confirmed > 0) {
_filePickerOnSelect?.Invoke(filename);
