diff options
author | Ask Solem <ask@celeryproject.org> | 2014-10-24 12:35:01 +0100 |
---|---|---|
committer | Ask Solem <ask@celeryproject.org> | 2014-10-24 12:35:01 +0100 |
commit | 185ce081e3efc846b476995b7da7297bb0eec82c (patch) | |
tree | 98adf852d24384b34b5a462907c2dce732c6821b /librabbitmq/amqp_consumer.c | |
parent | be3000b4c84d7503f5ef4067de44ff16d060d158 (diff) | |
parent | 9626dd5cd5f78894f1416a1afd2d624ddd4904ae (diff) | |
download | rabbitmq-c-github-ask-185ce081e3efc846b476995b7da7297bb0eec82c.tar.gz |
Diffstat (limited to 'librabbitmq/amqp_consumer.c')
-rw-r--r-- | librabbitmq/amqp_consumer.c | 15 |
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; |