Parcourir la source

fix a case where the encoding buffer was not exchanged

Julius Pfrommer il y a 7 ans
Parent
commit
945ea49d33
1 fichiers modifiés avec 9 ajouts et 0 suppressions
  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;