Skip to content

Make malloc(0) always return NULL#1427

Merged
saghul merged 2 commits intomasterfrom
malloz-zero
Mar 27, 2026
Merged

Make malloc(0) always return NULL#1427
saghul merged 2 commits intomasterfrom
malloz-zero

Conversation

@saghul
Copy link
Copy Markdown
Contributor

@saghul saghul commented Mar 27, 2026

  • Ensure we never call malloc for zero
  • Fix UBsan: applying zero offset to null pointer

Comment thread quickjs.c
p->u.typed_array = ta;
p->u.array.count = len;
p->u.array.u.ptr = abuf->data + offset;
p->u.array.u.ptr = abuf->data ? abuf->data + offset : NULL;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect our CI didn't trip because of ASAN + malloc(0)

@saghul saghul merged commit f8b3674 into master Mar 27, 2026
122 checks passed
@saghul saghul deleted the malloz-zero branch March 27, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants