mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 23:58:06 +02:00
LCL: Consider that MemSize can return 0 with a custom MemoryManager. Merge request !27 by Sergey Larin.
This commit is contained in:
parent
8af9cd0918
commit
75aebbee85
@ -1553,11 +1553,11 @@ begin
|
||||
Result := False;
|
||||
|
||||
//Sanity Checks For Vertices Size vs. Count
|
||||
if MemSize(Vertices) < PtrUInt(SizeOf(TTriVertex) * NumVertices) then
|
||||
if MemSizeLessThan(MemSize(Vertices), PtrUInt(SizeOf(TTriVertex) * NumVertices)) then
|
||||
Exit;
|
||||
|
||||
//Sanity Checks For Meshes Size vs. Count
|
||||
if MemSize(Meshes) < (MeshSize[DoFillTriangle] * Cardinal(NumMeshes)) then
|
||||
if MemSizeLessThan(MemSize(Meshes), (MeshSize[DoFillTriangle] * Cardinal(NumMeshes))) then
|
||||
Exit;
|
||||
|
||||
for I := 0 to NumMeshes - 1 do
|
||||
|
@ -176,6 +176,8 @@ type
|
||||
function GetDefaultLCLWidgetType: TLCLPlatform;
|
||||
function GetLCLWidgetTypeName: string;
|
||||
|
||||
function MemSizeLessThan(AMemSize, AThen: PtrUInt): Boolean; inline;
|
||||
|
||||
const
|
||||
{ Constants for the routine TWidgetSet.GetLCLCapability }
|
||||
LCL_CAPABILITY_NO = 0;
|
||||
@ -233,6 +235,11 @@ begin
|
||||
Result:=LCLPlatformDirNames[GetDefaultLCLWidgetType];
|
||||
end;
|
||||
|
||||
function MemSizeLessThan(AMemSize, AThen: PtrUInt): Boolean; inline;
|
||||
begin
|
||||
Result:=(AMemSize<>0) and (AMemSize<AThen);
|
||||
end;
|
||||
|
||||
{ TDialogButtons }
|
||||
|
||||
procedure TDialogButtons.SetCancelButton(const AValue: TDialogButton);
|
||||
|
@ -2477,7 +2477,7 @@ begin
|
||||
Result := False;
|
||||
|
||||
//Sanity Checks For Vertices Size vs. Count
|
||||
if MemSize(Vertices) < PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices) then
|
||||
if MemSizeLessThan(MemSize(Vertices), PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices)) then
|
||||
exit;
|
||||
|
||||
for I := 0 to NumMeshes - 1 do
|
||||
|
@ -4468,11 +4468,11 @@ begin
|
||||
Result := False;
|
||||
|
||||
//Sanity Checks For Vertices Size vs. Count
|
||||
if MemSize(Vertices) < PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices) then
|
||||
if MemSizeLessThan(MemSize(Vertices), PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices)) then
|
||||
exit;
|
||||
|
||||
//Sanity Checks For Meshes Size vs. Count
|
||||
if MemSize(Meshes) < PtrUInt(MeshSize[DoFillTriangle]*NumMeshes) then
|
||||
if MemSizeLessThan(MemSize(Meshes), PtrUInt(MeshSize[DoFillTriangle]*NumMeshes)) then
|
||||
exit;
|
||||
|
||||
for I := 0 to NumMeshes - 1 do
|
||||
|
@ -4544,11 +4544,11 @@ begin
|
||||
Result := False;
|
||||
|
||||
//Sanity Checks For Vertices Size vs. Count
|
||||
if MemSize(Vertices) < PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices) then
|
||||
if MemSizeLessThan(MemSize(Vertices), PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices)) then
|
||||
exit;
|
||||
|
||||
//Sanity Checks For Meshes Size vs. Count
|
||||
if MemSize(Meshes) < PtrUInt(MeshSize[DoFillTriangle]*NumMeshes) then
|
||||
if MemSizeLessThan(MemSize(Meshes), PtrUInt(MeshSize[DoFillTriangle]*NumMeshes)) then
|
||||
exit;
|
||||
|
||||
for I := 0 to NumMeshes - 1 do
|
||||
|
@ -4528,11 +4528,11 @@ begin
|
||||
Result := False;
|
||||
|
||||
//Sanity Checks For Vertices Size vs. Count
|
||||
if MemSize(Vertices) < PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices) then
|
||||
if MemSizeLessThan(MemSize(Vertices), PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices)) then
|
||||
exit;
|
||||
|
||||
//Sanity Checks For Meshes Size vs. Count
|
||||
if MemSize(Meshes) < PtrUInt(MeshSize[DoFillTriangle]*NumMeshes) then
|
||||
if MemSizeLessThan(MemSize(Meshes), PtrUInt(MeshSize[DoFillTriangle]*NumMeshes)) then
|
||||
exit;
|
||||
|
||||
for I := 0 to NumMeshes - 1 do
|
||||
|
@ -1763,7 +1763,7 @@ begin
|
||||
BitSize := longint(SizeOf(Byte))
|
||||
*(longint(biSizeImage) div biHeight)
|
||||
*longint(NumScans + StartScan);
|
||||
if MemSize(Bits) < PtrInt(BitSize)
|
||||
if MemSizeLessThan(MemSize(Bits), PtrInt(BitSize))
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.InternalGetDIBits] not enough memory allocated for Bits!');
|
||||
exit;
|
||||
|
@ -6676,11 +6676,11 @@ begin
|
||||
Result := False;
|
||||
|
||||
//Sanity Checks For Vertices Size vs. Count
|
||||
if MemSize(Vertices) < PtrInt(SizeOf(tagTRIVERTEX)*NumVertices) then
|
||||
if MemSizeLessThan(MemSize(Vertices), PtrInt(SizeOf(tagTRIVERTEX)*NumVertices)) then
|
||||
exit;
|
||||
|
||||
//Sanity Checks For Meshes Size vs. Count
|
||||
if MemSize(Meshes) < PtrInt(MeshSize[DoFillTriangle]*NumMeshes) then
|
||||
if MemSizeLessThan(MemSize(Meshes), PtrInt(MeshSize[DoFillTriangle]*NumMeshes)) then
|
||||
exit;
|
||||
|
||||
for I := 0 to NumMeshes - 1 do
|
||||
|
@ -2991,7 +2991,7 @@ begin
|
||||
BitSize := longint(SizeOf(Byte))
|
||||
*(longint(biSizeImage) div biHeight)
|
||||
*longint(NumScans + StartScan);
|
||||
if MemSize(Bits) < PtrInt(BitSize)
|
||||
if MemSizeLessThan(MemSize(Bits), PtrInt(BitSize))
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtk2WidgetSet.InternalGetDIBits] not enough memory allocated for Bits!');
|
||||
exit;
|
||||
|
@ -4810,11 +4810,11 @@ begin
|
||||
Result := False;
|
||||
|
||||
//Sanity Checks For Vertices Size vs. Count
|
||||
if MemSize(Vertices) < PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices) then
|
||||
if MemSizeLessThan(MemSize(Vertices), PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices)) then
|
||||
exit;
|
||||
|
||||
//Sanity Checks For Meshes Size vs. Count
|
||||
if MemSize(Meshes) < PtrUInt(MeshSize[DoFillTriangle]*NumMeshes) then
|
||||
if MemSizeLessThan(MemSize(Meshes), PtrUInt(MeshSize[DoFillTriangle]*NumMeshes)) then
|
||||
exit;
|
||||
|
||||
for I := 0 to NumMeshes - 1 do
|
||||
|
@ -4752,11 +4752,11 @@ begin
|
||||
Result := False;
|
||||
|
||||
//Sanity Checks For Vertices Size vs. Count
|
||||
if MemSize(Vertices) < PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices) then
|
||||
if MemSizeLessThan(MemSize(Vertices), PtrUInt(SizeOf(tagTRIVERTEX)*NumVertices)) then
|
||||
exit;
|
||||
|
||||
//Sanity Checks For Meshes Size vs. Count
|
||||
if MemSize(Meshes) < PtrUInt(MeshSize[DoFillTriangle]*NumMeshes) then
|
||||
if MemSizeLessThan(MemSize(Meshes), PtrUInt(MeshSize[DoFillTriangle]*NumMeshes)) then
|
||||
exit;
|
||||
|
||||
for I := 0 to NumMeshes - 1 do
|
||||
|
Loading…
Reference in New Issue
Block a user