summaryrefslogtreecommitdiff
path: root/librabbitmq/amqp_consumer.c
diff options
context:
space:
mode:
Diffstat (limited to 'librabbitmq/amqp_consumer.c')
-rw-r--r--librabbitmq/amqp_consumer.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/librabbitmq/amqp_consumer.c b/librabbitmq/amqp_consumer.c
index 6c6c1c9..cf08fd5 100644
--- a/librabbitmq/amqp_consumer.c
+++ b/librabbitmq/amqp_consumer.c
@@ -3,7 +3,7 @@
* ***** BEGIN LICENSE BLOCK *****
* Version: MIT
*
- * Portions created by Alan Antonuk are Copyright (c) 2013
+ * Portions created by Alan Antonuk are Copyright (c) 2013-2014
* Alan Antonuk. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person
@@ -131,6 +131,13 @@ void amqp_destroy_envelope(amqp_envelope_t *envelope)
amqp_bytes_free(envelope->consumer_tag);
}
+static
+int amqp_bytes_malloc_dup_failed(amqp_bytes_t bytes) {
+ if (bytes.len != 0 && bytes.bytes == NULL) {
+ return 1;
+ }
+ return 0;
+}
amqp_rpc_reply_t
amqp_consume_message(amqp_connection_state_t state, amqp_envelope_t *envelope,
@@ -168,9 +175,9 @@ amqp_consume_message(amqp_connection_state_t state, amqp_envelope_t *envelope,
envelope->exchange = amqp_bytes_malloc_dup(delivery_method->exchange);
envelope->routing_key = amqp_bytes_malloc_dup(delivery_method->routing_key);
- if (NULL == envelope->consumer_tag.bytes ||
- NULL == envelope->exchange.bytes ||
- NULL == envelope->routing_key.bytes) {
+ if (amqp_bytes_malloc_dup_failed(envelope->consumer_tag) ||
+ amqp_bytes_malloc_dup_failed(envelope->exchange) ||
+ amqp_bytes_malloc_dup_failed(envelope->routing_key)) {
ret.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
ret.library_error = AMQP_STATUS_NO_MEMORY;
goto error_out2;