Skip to content
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

Fix FFI Parsing of Pointer Declaration Lists #17794

Merged
merged 2 commits into from
Feb 17, 2025
Merged

Conversation

davnotdev
Copy link
Contributor

struct MyStruct {
    uint8_t** a, *b, c;
};

When a struct is defined in this form, the "base type" of a, b, and c is uint8_t**, so a will be uint8_t**, b will be uint8_t***, and c will be uint8_t**. This PR fixes the issue and adds a test case for it.

@bwoebi
Copy link
Member

bwoebi commented Feb 14, 2025

This file is generated from ext/ffi/ffi.g, so you should fix that one too.

But thanks for fixing and the test!

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

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

@davnotdev thanks for catching and fixing this.
@bwoebi thank you for the grammar correction.

@dstogov dstogov merged commit 52c91f0 into php:PHP-8.3 Feb 17, 2025
9 checks passed
dstogov added a commit that referenced this pull request Feb 17, 2025
* PHP-8.3:
  Fix FFI Parsing of Pointer Declaration Lists (#17794)
dstogov added a commit that referenced this pull request Feb 17, 2025
* PHP-8.4:
  Fix FFI Parsing of Pointer Declaration Lists (#17794)
@dstogov
Copy link
Member

dstogov commented Feb 17, 2025

The test case might be simplified, but the existing one is also good enough.

$ffi = FFI::cdef(<<<EOF
    struct MyStruct {
        uint8_t** a, *b, c;
    };
EOF);
$x = $ffi->new("struct MyStruct");
var_dump(FFI::typeof($x->a));
var_dump(FFI::typeof($x->b));
var_dump(FFI::typeof($x->c));

nielsdos added a commit that referenced this pull request Feb 17, 2025
[ci skip]
nielsdos added a commit that referenced this pull request Feb 17, 2025
nielsdos added a commit that referenced this pull request Feb 17, 2025
* PHP-8.4:
  NEWS for GH-17794
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.

3 participants