Compare commits

...

2 Commits

Author SHA1 Message Date
Lephenixnoir e26a96364c
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.
2023-07-17 23:02:55 +02:00
Lephenixnoir 99c89e5628
azrp: fix triangle shader not rendering when w=1 or h=1 2023-07-17 22:58:14 +02:00
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -64,7 +64,7 @@ void azrp_triangle(int x1, int y1, int x2, int y2, int x3, int y3, int color)
int min_y = max(0, min(y1, min(y2, y3)));
int max_y = min(azrp_height-1, max(y1, max(y2, y3)));
if(min_x >= max_x || min_y >= max_y) {
if(min_x > max_x || min_y > max_y) {
prof_leave(azrp_perf_cmdgen);
return;
}