[fpc-devel] Overflow in TMemoryStream?
mse00000 at gmail.com
Sun Sep 11 10:35:37 CEST 2016
While working on the MSEgui fork of classes unit I saw a suspect piece of code
function TMemoryStream.Realloc(var NewCapacity: PtrInt): Pointer;
If NewCapacity<0 Then
// if growing, grow at least a quarter
if (NewCapacity>FCapacity) and (NewCapacity < (5*FCapacity) div 4) then
NewCapacity := (5*FCapacity) div 4;
Isn't there an overflow if the capacity grows above high(ptrint) div 5 (about
430MB on 32 bit)?
IIRC there was a discussion on the list about memory problems with big
More information about the fpc-devel