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

id field in pattern and match callback does not match #34

Open
virusdefender opened this issue Nov 11, 2024 · 0 comments
Open

id field in pattern and match callback does not match #34

virusdefender opened this issue Nov 11, 2024 · 0 comments

Comments

@virusdefender
Copy link

virusdefender commented Nov 11, 2024

pub struct Pattern {
/// The expression to parse.
pub expression: String,
/// Flags which modify the behaviour of the expression.
pub flags: Flags,
/// ID number to be associated with the corresponding pattern in the expressions array.
pub id: Option<usize>,
/// Extended behaviour for this pattern
pub ext: ExprExt,
/// The precision to track start of match offsets in stream state.
pub som: Option<SomHorizon>,
}

the id field in Pattern is usize, but it's c_uint / u32 in the hs_compile_multi and match_event_handler

pub fn hs_compile_multi(
expressions: *const *const ::libc::c_char,
flags: *const ::libc::c_uint,
ids: *const ::libc::c_uint,
elements: ::libc::c_uint,
mode: ::libc::c_uint,
platform: *const hs_platform_info_t,
db: *mut *mut hs_database_t,
error: *mut *mut hs_compile_error_t,
) -> hs_error_t;
}

pub type match_event_handler = ::core::option::Option<
unsafe extern "C" fn(
id: ::libc::c_uint,
from: ::libc::c_ulonglong,
to: ::libc::c_ulonglong,
flags: ::libc::c_uint,
context: *mut ::libc::c_void,
) -> ::libc::c_int,
>;

if pattern.id > u32.Max, it will be truncated while compiling database, and then the callback id will be wrong.

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

No branches or pull requests

1 participant