ensure command alignment is correct

This commit is contained in:
Jan200101 2021-10-28 08:40:18 +02:00 committed by Guldoman
parent c3ca98b4f7
commit 73019fc902
No known key found for this signature in database
GPG Key ID: C08A498EC7F1AFDD
1 changed files with 3 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdalign.h>
#include <lauxlib.h>
#include "rencache.h"
@ -124,6 +125,8 @@ static RenRect merge_rects(RenRect a, RenRect b) {
static Command* push_command(int type, int size) {
size_t alignment = alignof(max_align_t) - 1;
size = (size + alignment) & ~alignment;
Command *cmd = (Command*) (command_buf + command_buf_idx);
int n = command_buf_idx + size;
if (n > COMMAND_BUF_SIZE) {