Selaa lähdekoodia

fix a case where the encoding buffer was not exchanged

Julius Pfrommer 7 vuotta sitten
vanhempi
commit
945ea49d33
1 muutettua tiedostoa jossa 9 lisäystä ja 0 poistoa
  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;