[PATCH 4/4] QPIDMSG: Fixed issue with reallocating vector fields


Frank Quinn <fquinn.ni@...>
 

This patch fixes an issue where a realloc occurs for member types which the
qpid bridge will typically attempt to re-use rather than create / destroy
every time. This is really just MAMA Message at this time but the same
would apply to date time and price if they were implemented. Without this
change, if the newly appended memory happens to be non-NULL, the qpid bridge
will likely crash.

Signed-off-by: Frank Quinn <fquinn@...>
---
 mama/c_cpp/src/c/payload/qpidmsg/payload.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mama/c_cpp/src/c/payload/qpidmsg/payload.c b/mama/c_cpp/src/c/payload/qpidmsg/payload.c
index 4bf8d9f..5699edb 100644
--- a/mama/c_cpp/src/c/payload/qpidmsg/payload.c
+++ b/mama/c_cpp/src/c/payload/qpidmsg/payload.c
@@ -3262,6 +3262,9 @@ qpidmsgPayloadImpl_allocateBufferMemory (void**       buffer,
         }
         else
         {
+            /* set newly added bytes to 0 */
+            memset ((uint8_t*) newbuf + *size, 0, newSize - *size);
+
             *buffer = newbuf;
             *size   = newSize;
             return MAMA_STATUS_OK;
--
1.9.3