ne0bot / delphionrails

Automatically exported from code.google.com/p/delphionrails
0 stars 0 forks source link

dorUtils.pas, Base64ToStream, range checks #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When debugging or running an application using the IDE with range checking 
enabled, Delphi throws "range check error" exceptions because some of the 
results assigned to buf[] exceed byte range.

This change solves the issue:

    // reverse process of above
    buf[0] := (((Base64Map[data[i]] shl byte(2)) or (Base64Map[data[i + 1]] shr byte(4)))) and $FF;
    buf[1] := ((Base64Map[data[i + 1]] shl 4) or (Base64Map[data[i + 2]] shr 2)) and $FF;
    buf[2] := ((Base64Map[data[i + 2]] shl 6) or (Base64Map[data[i + 3]])) and $FF;

Original issue reported on code.google.com by schnaade...@gmail.com on 16 Mar 2012 at 3:26

GoogleCodeExporter commented 8 years ago

Original comment by hgourv...@gmail.com on 13 Feb 2014 at 4:33