Menu

#146 Out of range error in GLGraphics.pas

open
nobody
None
5
2010-06-14
2010-06-14
No

Since rev 1.63 of GLGraphics.pas (Integer -> PtrUInt), Delphi throw an "Out of range" exception

In:
rowOffset := PtrUInt(BitmapScanLine(aBitmap, Height - 2)) - PtrUInt(pSrc)
The result can be negative.

We should revert all PtrUInt to ptrInt ?

Discussion

  • YarUnderoaker

    YarUnderoaker - 2010-06-14

    In 64-bit platforms an arifmetic operations with pointer must be doing with conversion it's to PtrUInt type. So maybe need to complitly rewrite this code.
    Besides, rowOffset is 32-bit integer and PtrUInt is 64-bit on x64 - not very correct assignment operation.

     
  • Yann Papouin

    Yann Papouin - 2010-06-14

    The main problem comes from the operation, by example the following line
    temp := Byte(1) - Byte(1);
    will raise an exception when range check is enabled even if temp is an integer

     
  • Yann Papouin

    Yann Papouin - 2010-07-24

    Ok my previous assertion was wrong
    delta := Int64(Byte(250) - Byte(254));
    do not raise any exception the result is valid.

    BUT

    delta:= int64(PtrUInt(newbase) - PtrUInt(oldbase));
    is raising an out of range exception
    (tested with
    newbase := Pointer(2140012872);
    oldbase := Pointer(2144797000);
    )

    the same thing with
    delta:= int64(PtrUInt(newbase)) - int64(PtrUInt(oldbase));
    do not raise any exception the result is valid.

    To my mind it's delphi int64 error, but I can be fixed by casting both arguments
    delta:= int64(PtrUInt(newbase)) - int64(PtrUInt(oldbase));

     
  • YarUnderoaker

    YarUnderoaker - 2010-07-24

    ok, go fix :)