Ignore:
Timestamp:
Feb 23, 2011, 8:57:12 AM (13 years ago)
Author:
george
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • CoolStreaming/UVarBlockSerializer.pas

    r173 r174  
    106106  SMaskedValueReadError = 'Error reading masked variable length block.';
    107107  SUInt64Overflow = '64-bit UInt read overflow.';
     108  SReadError = 'Stream read error. Expected length %d, read %d. Source stream size %d.';
    108109
    109110{ TVarBlockSerializer }
     
    365366  Data: Byte;
    366367  Length: Cardinal;
    367   I: Cardinal;
     368  RealLength: Cardinal;
    368369  LengthMask: Byte;
    369370begin
    370371  AStream.Size := 0;
    371   I := 0;
    372372  Length := 1;
    373373
     
    400400
    401401  // If CopyFrom parameter count is zero then whole source is copied
    402   if Length > 1 then
    403     AStream.CopyFrom(Stream, Length - 1);
     402  if Length > 1 then begin
     403    RealLength := AStream.CopyFrom(Stream, Length - 1);
     404    if RealLength < (Length - 1) then
     405      raise EReadError.Create(Format(SReadError, [Length - 1, RealLength, Stream.Size]));
     406  end;
    404407  AStream.Position := 0;
    405408end;
     
    413416  Result := 1; // Byte block length
    414417  Data := Stream.ReadByte;
    415   if Data = $ff then Result := ReadVarUInt + 2
     418  if Data = $ff then Result := GetVarSize + ReadVarUInt + 1
    416419  else begin
    417420    Result := DecodeUnaryLength(Data);
Note: See TracChangeset for help on using the changeset viewer.