Merge pull request #8 from dtolnay/handler

Disallow None handler function argument
This commit is contained in:
David Tolnay 2022-07-23 15:19:00 -07:00 committed by GitHub
commit f77851265b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 11 deletions

View file

@ -17,7 +17,7 @@ unsafe fn fuzz_target(mut data: &[u8]) {
let mut parser = MaybeUninit::<yaml_parser_t>::uninit();
let parser = parser.as_mut_ptr();
assert!(yaml_parser_initialize(parser).ok);
yaml_parser_set_input(parser, Some(read_from_slice), addr_of_mut!(data).cast());
yaml_parser_set_input(parser, read_from_slice, addr_of_mut!(data).cast());
let mut document = MaybeUninit::<yaml_document_t>::uninit();
let document = document.as_mut_ptr();

View file

@ -17,7 +17,7 @@ unsafe fn fuzz_target(mut data: &[u8]) {
let mut parser = MaybeUninit::<yaml_parser_t>::uninit();
let parser = parser.as_mut_ptr();
assert!(yaml_parser_initialize(parser).ok);
yaml_parser_set_input(parser, Some(read_from_slice), addr_of_mut!(data).cast());
yaml_parser_set_input(parser, read_from_slice, addr_of_mut!(data).cast());
let mut event = MaybeUninit::<yaml_event_t>::uninit();
let event = event.as_mut_ptr();

View file

@ -17,7 +17,7 @@ unsafe fn fuzz_target(mut data: &[u8]) {
let mut parser = MaybeUninit::<yaml_parser_t>::uninit();
let parser = parser.as_mut_ptr();
assert!(yaml_parser_initialize(parser).ok);
yaml_parser_set_input(parser, Some(read_from_slice), addr_of_mut!(data).cast());
yaml_parser_set_input(parser, read_from_slice, addr_of_mut!(data).cast());
let mut token = MaybeUninit::<yaml_token_t>::uninit();
let token = token.as_mut_ptr();

View file

@ -316,14 +316,13 @@ pub unsafe fn yaml_parser_set_input_string(
/// Set a generic input handler.
pub unsafe fn yaml_parser_set_input(
parser: *mut yaml_parser_t,
handler: Option<yaml_read_handler_t>,
handler: yaml_read_handler_t,
data: *mut libc::c_void,
) {
__assert!(!parser.is_null());
__assert!(((*parser).read_handler).is_none());
__assert!(handler.is_some());
let fresh89 = addr_of_mut!((*parser).read_handler);
*fresh89 = handler;
*fresh89 = Some(handler);
let fresh90 = addr_of_mut!((*parser).read_handler_data);
*fresh90 = data;
}
@ -472,14 +471,13 @@ pub unsafe fn yaml_emitter_set_output_string(
/// Set a generic output handler.
pub unsafe fn yaml_emitter_set_output(
emitter: *mut yaml_emitter_t,
handler: Option<yaml_write_handler_t>,
handler: yaml_write_handler_t,
data: *mut libc::c_void,
) {
__assert!(!emitter.is_null());
__assert!(((*emitter).write_handler).is_none());
__assert!(handler.is_some());
let fresh161 = addr_of_mut!((*emitter).write_handler);
*fresh161 = handler;
*fresh161 = Some(handler);
let fresh162 = addr_of_mut!((*emitter).write_handler_data);
*fresh162 = data;
}

View file

@ -60,7 +60,7 @@ pub(crate) unsafe fn unsafe_main(
}
}
yaml_emitter_set_output(emitter, Some(write_to_stdio), addr_of_mut!(stdout).cast());
yaml_emitter_set_output(emitter, write_to_stdio, addr_of_mut!(stdout).cast());
yaml_emitter_set_canonical(emitter, false);
yaml_emitter_set_unicode(emitter, false);

View file

@ -61,7 +61,7 @@ pub(crate) unsafe fn unsafe_main(
}
}
yaml_parser_set_input(parser, Some(read_from_stdio), addr_of_mut!(stdin).cast());
yaml_parser_set_input(parser, read_from_stdio, addr_of_mut!(stdin).cast());
let mut event = MaybeUninit::<yaml_event_t>::uninit();
let event = event.as_mut_ptr();