summaryrefslogtreecommitdiff
path: root/librabbitmq
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2013-07-10 10:37:20 -0700
committerAlan Antonuk <alan.antonuk@gmail.com>2013-07-10 10:37:20 -0700
commit157788ef441a95e09cdf19b8988445f749e3316d (patch)
tree9ee585abd00dd6ce9d4a5cc05e32417bac6514bb /librabbitmq
parent7942af3ac63cfc86090dbc8a70c5bd0673ac30cf (diff)
downloadrabbitmq-c-github-ask-157788ef441a95e09cdf19b8988445f749e3316d.tar.gz
FIX: basic_properties_clone handle 0-len strings
Properly handle 0-length strings in amqp_basic_properties_clone()
Diffstat (limited to 'librabbitmq')
-rw-r--r--librabbitmq/amqp_consumer.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/librabbitmq/amqp_consumer.c b/librabbitmq/amqp_consumer.c
index 25b676e..29da9ed 100644
--- a/librabbitmq/amqp_consumer.c
+++ b/librabbitmq/amqp_consumer.c
@@ -42,12 +42,16 @@ int amqp_basic_properties_clone(amqp_basic_properties_t *original,
memset(clone, 0, sizeof(amqp_basic_properties_t));
clone->_flags = original->_flags;
-#define CLONE_BYTES_POOL(original, clone, pool) \
- amqp_pool_alloc_bytes(pool, original.len, &clone); \
- if (NULL == clone.bytes) { \
- return AMQP_STATUS_NO_MEMORY; \
- } \
- memcpy(clone.bytes, original.bytes, clone.len);
+#define CLONE_BYTES_POOL(original, clone, pool) \
+ if (0 == original.len) { \
+ clone = amqp_empty_bytes; \
+ } else { \
+ amqp_pool_alloc_bytes(pool, original.len, &clone); \
+ if (NULL == clone.bytes) { \
+ return AMQP_STATUS_NO_MEMORY; \
+ } \
+ memcpy(clone.bytes, original.bytes, clone.len); \
+ }
if (clone->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) {
CLONE_BYTES_POOL(original->content_type, clone->content_type, pool)