fixed some error: Block

This commit is contained in:
free will committed 2021-03-23 17:43:46 +08:00
1 parent 3daf0156e0
commit 99d7f94fec
1 file changed
+8 -8
+8 -8
View File
@@ -343,16 +343,16 @@ public class Block {
if(this.hasValue()){
// 如果设置了 value ,则直接使用
int tmplen=encoder.appendByteArray(this.value,new SizeT(this.value.length));
if(tmplen==0){
return 0;
if(tmplen<=0){
return -1;
}
len+=tmplen;
}else{
// 如果 value 为空,则看 elements 中有没有子TLV Block,有则编码后插入
for(Block subBlock:this.elements.getElements()){
int tmplen=subBlock.encode(encoder);
if(tmplen==0){
return 0;
if(tmplen<=0){
return -1;
}
len+=tmplen;
}
@@ -360,15 +360,15 @@ public class Block {
// 编码 TLV-LENGTH
int tmplen=encoder.prependVarNumber(new VlInt(len));
if(tmplen==0){
return 0;
if(tmplen<=0){
return -1;
}
len+=tmplen;
// 编码 TLV-TYPE
tmplen=encoder.prependVarNumber(this.tlvType);
if(tmplen==0){
return 0;
if(tmplen<=0){
return -1;
}
len+=tmplen;