[fpc-devel] Overflow in TMemoryStream?
    Martin Schreiber 
    mse00000 at gmail.com
       
    Sun Sep 11 10:35:37 CEST 2016
    
    
  
Hi,
While working on the MSEgui fork of classes unit I saw a suspect piece of code 
in streams.inc:
"
function TMemoryStream.Realloc(var NewCapacity: PtrInt): Pointer;
begin
  If NewCapacity<0 Then
    NewCapacity:=0
  else
    begin
      // 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 
TMemoryStream's.
Martin
    
    
More information about the fpc-devel
mailing list