Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid variable lengths arrays #368

Merged
merged 2 commits into from
Apr 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions amqp_connection_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,7 @@ amqp_connection_resource *connection_resource_constructor(amqp_connection_params
amqp_table_entry_t client_properties_entries[5];
amqp_table_t client_properties_table;

int custom_properties_entries_len;
if (params->connection_name) {
custom_properties_entries_len = 2;
} else {
custom_properties_entries_len = 1;
}
amqp_table_entry_t custom_properties_entries[custom_properties_entries_len];
amqp_table_entry_t custom_properties_entries[2];
amqp_table_t custom_properties_table;

amqp_connection_resource *resource;
Expand Down Expand Up @@ -540,7 +534,7 @@ amqp_connection_resource *connection_resource_constructor(amqp_connection_params
}

custom_properties_table.entries = custom_properties_entries;
custom_properties_table.num_entries = sizeof(custom_properties_entries) / sizeof(amqp_table_entry_t);
custom_properties_table.num_entries = params->connection_name ? 2 : 1;

/* We can assume that connection established here but it is not true, real handshake goes during login */

Expand Down