Skip to content

Make malloc(0) always return NULL - #1427

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

saghul merged 2 commits into
masterfrom
malloz-zero

Conversation

@saghul

@saghul saghul commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
  • 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