浏览代码

* Safety for empty asJSON. Should not happen, but better safe than sorry

git-svn-id: trunk@42784 -
michael 6 年之前
父节点
当前提交
b38596b925
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      packages/fcl-web/src/jsonrpc/webjsonrpc.pp

+ 2 - 1
packages/fcl-web/src/jsonrpc/webjsonrpc.pp

@@ -275,7 +275,8 @@ begin
       AResponse.FreeContentStream:=True;
       AResponse.FreeContentStream:=True;
       AResponse.ContentStream:=TMemoryStream.Create;
       AResponse.ContentStream:=TMemoryStream.Create;
       R:=Res.AsJSON;
       R:=Res.AsJSON;
-      AResponse.ContentStream.WriteBuffer(R[1],Length(R));
+      if Length(R)>0 then
+        AResponse.ContentStream.WriteBuffer(R[1],Length(R));
       AResponse.ContentLength:=AResponse.ContentStream.Size;
       AResponse.ContentLength:=AResponse.ContentStream.Size;
       R:=''; // Free up mem
       R:=''; // Free up mem
       AResponse.ContentType:=GetResponseContentType;
       AResponse.ContentType:=GetResponseContentType;