diff options
author | Alan Antonuk <alan.antonuk@gmail.com> | 2013-07-10 10:44:41 -0700 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2013-07-10 11:09:39 -0700 |
commit | 4eaf771fa5f7807c38276b26aaa410bfd136d382 (patch) | |
tree | 9078df9d7384c8870f67ea0a47f2e61c9ecf6bd2 /librabbitmq/amqp_consumer.c | |
parent | 157788ef441a95e09cdf19b8988445f749e3316d (diff) | |
download | rabbitmq-c-4eaf771fa5f7807c38276b26aaa410bfd136d382.tar.gz |
FIX: handle 0-len msg body in amqp_read_message
Diffstat (limited to 'librabbitmq/amqp_consumer.c')
-rw-r--r-- | librabbitmq/amqp_consumer.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/librabbitmq/amqp_consumer.c b/librabbitmq/amqp_consumer.c index 29da9ed..6fb5b96 100644 --- a/librabbitmq/amqp_consumer.c +++ b/librabbitmq/amqp_consumer.c @@ -242,11 +242,15 @@ amqp_rpc_reply_t amqp_read_message(amqp_connection_state_t state, goto error_out3; } - message->body = amqp_bytes_malloc(frame.payload.properties.body_size); - if (NULL == message->body.bytes) { - ret.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - ret.library_error = AMQP_STATUS_NO_MEMORY; - goto error_out1; + if (0 == frame.payload.properties.body_size) { + message->body = amqp_empty_bytes; + } else { + message->body = amqp_bytes_malloc(frame.payload.properties.body_size); + if (NULL == message->body.bytes) { + ret.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + ret.library_error = AMQP_STATUS_NO_MEMORY; + goto error_out1; + } } body_read = 0; |