[Mono-list] Some bugs on Mono.DataConverter

Luis Gomes lmagomes at gmail.com
Wed May 30 14:43:49 EDT 2007


Hello, I have some fixes/questions/ideas about Mono.DataConverter.cs

1 -
On line 1229/1230 and 1239/1240 on PutBytesLE and PutBytesBE:
for (; i < count; i++)
	dest [i-count] = *src++;

This starts putting data on an address that does not belong to the
pointer (a negative value), crashes mono (on Linux), and makes it
return a wrong value on Microsoft .net 2.0.

I changed it to:
dest = &dest [count-1];
for (; i < count; i++)
	*dest-- = *src++;

Don't know if it is the best way, but I attached a patch.


2 -
It doesn't compile on Microsoft .net 2.0 because of the definition of
the var n inside the switch statements on lines 482 and 708, and
"fixed (byte* target = (&dest[destIdx]))" on line 974.

The last error goes away if you use "fixed (byte* target =
&dest[destIdx])" like it is used in the other overloaded PutBytes
methods, and I don't see any problem with that.

The declaration of var n could be done before entering the switch
statement, but I don't know if it is the best way. I can just compile
it with mono on Linux, and use it on MS .net so I guess this isn't
very problematic, at least for me, but if you want I can do some tests
and submit a patch.

3 -
Any problems on having the XXXFromXE (byte [] data, int index) methods
overloaded with an index of always 0? I'm not sure if there is a good
reason for it not being there, but if there is none, and you are OK
with it, I can also do it and submit a patch.

Thanks for your time, and keep up the good work,
Luis Gomes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DataConverter.patch
Type: text/x-patch
Size: 634 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20070530/c5057d5e/attachment.bin 


More information about the Mono-list mailing list