Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

Commit

Permalink
Align command size to fix undefined behavior
Browse files Browse the repository at this point in the history
Merged rxi#67

Merge branch 'master' of github.com:gaultier/microui
  • Loading branch information
namandixit committed Oct 29, 2024
2 parents 98a322b + 654a0b0 commit 7698cda
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/microui.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ void mu_input_text(mu_Context *ctx, const char *text) {
**============================================================================*/

mu_Command* mu_push_command(mu_Context *ctx, int type, int size) {
// Need to pad to the next multiple of 8 to respect alignment requirements.
size = (size+7) & -8;

mu_Command *cmd = (mu_Command*) (ctx->command_list.items + ctx->command_list.idx);
expect(ctx->command_list.idx + size < MU_COMMANDLIST_SIZE);
cmd->base.type = type;
Expand Down

0 comments on commit 7698cda

Please sign in to comment.