danieleteti / delphimvcframework

DMVCFramework (for short) is a popular and powerful framework for WEB API in Delphi. Supports RESTful and JSON-RPC WEB APIs development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Range Check Error in TMVCStreamHelper

dipold opened this issue · comments

Case the Range checking is True in Project Options > Delphi Compiler > Compiling, I am getting Range check error when AString is empty in this code:

Self.WriteBuffer(UFTStr[low(UFTStr)], Length(UFTStr));

I think it would be enough to check if the parameter is empty:

procedure TMVCStreamHelper.WriteUTF8(const AString: string);
var
  UFTStr: UTF8String;
begin
  UFTStr := UTF8String(AString);
  if (UFTStr <> '') then
    Self.WriteBuffer(UFTStr[Low(UFTStr)], Length(UFTStr));
end;