Skip to content

Commit

Permalink
Correctly handle NULL GError** out parameters
Browse files Browse the repository at this point in the history
Fixes #1671
  • Loading branch information
sdroege authored and bilelmoussaoui committed Apr 3, 2024
1 parent 6a7f477 commit 5fe566e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions gdk4/src/subclass/content_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ unsafe extern "C" fn content_provider_write_mime_type_finish(
true.into_glib()
}
Err(e) => {
*error_ptr = e.into_glib_ptr();
if !error_ptr.is_null() {
*error_ptr = e.into_glib_ptr();
}
false.into_glib()
}
}
Expand All @@ -404,7 +406,9 @@ unsafe extern "C" fn content_provider_get_value<T: ContentProviderImpl>(
true.into_glib()
}
Err(e) => {
*error_ptr = e.into_glib_ptr();
if !error_ptr.is_null() {
*error_ptr = e.into_glib_ptr();
}
false.into_glib()
}
}
Expand Down
4 changes: 3 additions & 1 deletion gtk4/src/subclass/builder_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ unsafe extern "C" fn builder_scope_create_closure<T: BuilderScopeImpl>(
match ret {
Ok(closure) => closure.into_glib_ptr(),
Err(e) => {
*errorptr = e.into_glib_ptr();
if !errorptr.is_null() {
*errorptr = e.into_glib_ptr();
}
std::ptr::null_mut()
}
}
Expand Down

0 comments on commit 5fe566e

Please sign in to comment.