Skip to content

std::bad_alloc() when header table is empty #326

@olii

Description

@olii

There is a bug when the AMQP header table has a nested table that is empty (0 entries). The exception std::bad_alloc() is thrown.

This is the line:

case AMQP_FIELD_KIND_TABLE:
new_value.value.table = CopyTableInner(value.value.table, pool);

Then this is called and it throws the exception:
amqp_table_t TableValueImpl::CopyTableInner(const amqp_table_t &table,
amqp_pool_t &pool) {
amqp_table_t new_table;
new_table.num_entries = table.num_entries;
new_table.entries = (amqp_table_entry_t *)amqp_pool_alloc(
&pool, sizeof(amqp_table_entry_t) * table.num_entries);
if (NULL == new_table.entries) {
throw std::bad_alloc();

I experience this by trying to consume the celery v5.3.1 event.
image
The stamps is a table that has no entries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions