azrp: fix a cmdgen bug causing crashes when buffer is full
Command finalization could refuse to finalize commands that were allocated, because its rounding method added 4 extra bytes to commands whose size is a multiple of 4. Such commands would still be instantiated but without commands_length advancing, causing the underlying memory to be reallocated later, leading to overlapping commands.
This commit is contained in:
parent
99c89e5628
commit
e26a96364c
|
@ -300,7 +300,7 @@ void *azrp_alloc_command(size_t size, int *extra, int count)
|
|||
void azrp_finalize_command(void const *command, int total_size)
|
||||
{
|
||||
(void)command;
|
||||
total_size = (total_size | 3) + 1;
|
||||
total_size = (total_size + 3) & -4;
|
||||
|
||||
if(commands_length + total_size > (int)sizeof commands_data)
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue