Re: [fpc-devel] Overflow in TMemoryStream?

2016-09-12 Thread Michael Van Canneyt
On Mon, 12 Sep 2016, Michael Van Canneyt wrote: So it looks like a 32 vs. 64 bit issue. from the method Realloc : NewCapacity := (5*FCapacity) div 4; // 5*FCapacity can cause overflow Changing this to NewCapacity:=FCapacity + (FCapacity div 4) Will probably fix the issue. I

Re: [fpc-devel] Overflow in TMemoryStream?

2016-09-12 Thread Michael Van Canneyt
On Sun, 11 Sep 2016, Martok wrote: Hi, yes, I can confirm this as an overflow, but on its own, it should be safe. Above 430MB, the stream doesn't grow by a quarter but just by however much was requested, luckily the branch fails before the wrong capacity could be set. Test: type TMS2 =

Re: [fpc-devel] Overflow in TMemoryStream?

2016-09-12 Thread Martok
Hi, yes, I can confirm this as an overflow, but on its own, it should be safe. Above 430MB, the stream doesn't grow by a quarter but just by however much was requested, luckily the branch fails before the wrong capacity could be set. Test: type TMS2 = class(TMemoryStream) end; var ms: TMS2;