浏览代码

fix a case where the encoding buffer was not exchanged

Julius Pfrommer 7 年之前
父节点
当前提交
945ea49d33
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/ua_types_encoding_binary.c

+ 9 - 0
src/ua_types_encoding_binary.c

@@ -510,6 +510,15 @@ Array_encodeBinary(const void *src, size_t length, const UA_DataType *type) {
 
     /* Encode the array length */
     UA_StatusCode retval = Int32_encodeBinary(&signed_length);
+
+    /* The buffer limit was reached during encoding of the length */
+    if(retval == UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED) {
+        retval = exchangeBuffer();
+        if(retval == UA_STATUSCODE_GOOD)
+            retval = Int32_encodeBinary(&signed_length);
+    }
+
+    /* Quit early? */
     if(retval != UA_STATUSCODE_GOOD || length == 0)
         return retval;