api: check id is valid for bounce checking

If the id is invalid we cannot check whether we must free the message or
not, free it anyway.

Type: fix

Change-Id: Ie4426f601390d1e5e14c739f670e8c1e6e3aaf1e
Signed-off-by: Benoît Ganne <bganne@cisco.com>
(cherry picked from commit ff13e46215ab96df988310b4a20eddefad92de99)
This commit is contained in:
Benoît Ganne
2020-01-21 18:33:14 +01:00
committed by Andrew Yourtchenko
parent 7f0abd5bd5
commit 6ed8162090

View File

@ -595,7 +595,7 @@ vl_msg_api_handler_with_vm_node (api_main_t * am,
* Special-case, so we can e.g. bounce messages off the vnet * Special-case, so we can e.g. bounce messages off the vnet
* main thread without copying them... * main thread without copying them...
*/ */
if (!(am->message_bounce[id])) if (id >= vec_len (am->message_bounce) || !(am->message_bounce[id]))
vl_msg_api_free (the_msg); vl_msg_api_free (the_msg);
if (PREDICT_FALSE (am->elog_trace_api_messages)) if (PREDICT_FALSE (am->elog_trace_api_messages))