This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/main by this push:
     new d6112ee  PROTON-2521: Fix null emission for emit_copy() and 
emit_multiple()
d6112ee is described below

commit d6112ee21dc695482b19288bd4d24169c70bf63c
Author: Andrew Stitcher <[email protected]>
AuthorDate: Mon Mar 14 17:14:25 2022 -0400

    PROTON-2521: Fix null emission for emit_copy() and emit_multiple()
---
 c/src/core/emitters.h | 47 +++++++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/c/src/core/emitters.h b/c/src/core/emitters.h
index 5a5614e..9b4ec1b 100644
--- a/c/src/core/emitters.h
+++ b/c/src/core/emitters.h
@@ -530,51 +530,54 @@ static inline void pni_emitter_data(pni_emitter_t* 
emitter, pn_data_t* data) {
 }
 
 static inline void emit_copy(pni_emitter_t* emitter, pni_compound_context* 
compound, pn_data_t* data) {
-  emit_accumulated_nulls(emitter, compound);
   if (!data || pn_data_size(data) == 0) {
-    pni_emitter_writef8(emitter, PNE_NULL);
-  } else {
-    pn_handle_t point = pn_data_point(data);
-    pn_data_rewind(data);
-    pni_emitter_data(emitter, data);
-    pn_data_restore(data, point);
+    emit_null(emitter, compound);
+    return;
   }
+
+  emit_accumulated_nulls(emitter, compound);
+  pn_handle_t point = pn_data_point(data);
+  pn_data_rewind(data);
+  pni_emitter_data(emitter, data);
+  pn_data_restore(data, point);
   compound->count++;
 }
 
 static inline void emit_multiple(pni_emitter_t* emitter, pni_compound_context* 
compound, pn_data_t* data) {
-  pn_handle_t point = {0};
-  if (data) {
-    point = pn_data_point(data);
-    pn_data_rewind(data);
-    // Rewind and position to first node so data type is defined.
-    pn_data_next(data);
+  if (!data || pn_data_size(data) == 0) {
+    emit_null(emitter, compound);
+    return;
   }
 
-  emit_accumulated_nulls(emitter, compound);
-  if (!data || pn_data_size(data) == 0) {
-    pni_emitter_writef8(emitter, PNE_NULL);
-  } else if (pn_data_type(data) == PN_ARRAY) {
-    switch (pn_data_get_array(data)) {
+  pn_handle_t point = pn_data_point(data);
+  pn_data_rewind(data);
+  // Rewind and position to first node so data type is defined.
+  pn_data_next(data);
+
+  if (pn_data_type(data) == PN_ARRAY) {
+      switch (pn_data_get_array(data)) {
       case 0:
-        pni_emitter_writef8(emitter, PNE_NULL);
-        break;
+        emit_null(emitter, compound);
+        pn_data_restore(data, point);
+        return;
       case 1:
+        emit_accumulated_nulls(emitter, compound);
         pn_data_enter(data);
         pn_data_narrow(data);
         pni_emitter_data(emitter, data);
         pn_data_widen(data);
         break;
       default:
+        emit_accumulated_nulls(emitter, compound);
         pni_emitter_data(emitter, data);
     }
   } else {
+    emit_accumulated_nulls(emitter, compound);
     pni_emitter_data(emitter, data);
   }
 
   compound->count++;
-  if (data)
-    pn_data_restore(data, point);
+  pn_data_restore(data, point);
 }
 
 static inline void emit_described_type_copy(pni_emitter_t* emitter, 
pni_compound_context* compound, uint64_t descriptor, pn_data_t* data) {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to