Skip to content

Fix UBSAN warning about applying zero offset to null pointer #10700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2023

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Feb 25, 2023

vpath may be NULL here so check for it before trying to add 0 (the length of the vpath) to it.

vpath may be NULL here so check for it before trying to add 0 (the length of the vpath) to it.
@nielsdos
Copy link
Member

Makes sense to me. Ig we could move the variable definition of const char *vpath = client->request.vpath; out of the if body and then check for vpath in the condition instead. However, the compiler should be smart enough to do that optimisation itself.

@Girgias
Copy link
Member Author

Girgias commented Feb 26, 2023

Makes sense to me. Ig we could move the variable definition of const char *vpath = client->request.vpath; out of the if body and then check for vpath in the condition instead. However, the compiler should be smart enough to do that optimisation itself.

I suppose, but I think it was scoped to support C89 compilers prior to us moving to C99, but yeah hopefully the compiler is smart enough to do this. :)

@Girgias Girgias merged commit 382148d into php:master Feb 26, 2023
@Girgias Girgias deleted the cli-sapi-ubsan branch February 26, 2023 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants