[Mono-bugs] [Bug 57706][Nor] New - Marshal.PtrToStringUni fails with Null IntPtr

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 27 Apr 2004 05:46:43 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jordi@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=57706

--- shadow/57706	2004-04-27 05:46:43.000000000 -0400
+++ shadow/57706.tmp.16154	2004-04-27 05:46:43.000000000 -0400
@@ -0,0 +1,36 @@
+Bug#: 57706
+Product: Mono: Runtime
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jordi@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Marshal.PtrToStringUni fails with Null IntPtr
+
+When you call Marshal.PtrToStringUni with a NULL IntPtr in fails in Mono
+and aborts the execution of the program. In Microsoft .Net, it return an
+empty string and you can continue running the problem.
+
+This behaviour is also a pain in the ass because you have to check for NULL
+IntPtr before calling PtrToStringUni, something that you do not need to do
+with the .Net runtime
+
+Here you have a small sample that ilustrates the problem:
+
+string s  = Marshal.PtrToStringUni (IntPtr.Zero);
+Console.WriteLine("str:" + s);
+
+When fixing this, I will also suggest to check PtrToStringAuto,
+PtrToStringAnsi and other Ptr to String functions to make sure that they
+work also properly.
+
+Jordi,