Commit 52dd9847 authored by Philip Withnall's avatar Philip Withnall
Browse files

gtlsbackend: Add missing preconditions for DTLS virtual methods



Make it a bit more obvious when the DTLS methods aren’t implemented by a
particular TLS backend; return an invalid type rather than crashing.
Signed-off-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=752240
parent 51e852e5
......@@ -230,14 +230,22 @@ g_tls_backend_get_server_connection_type (GTlsBackend *backend)
* Gets the #GType of @backend’s #GDtlsClientConnection implementation.
*
* Returns: the #GType of @backend’s #GDtlsClientConnection
* implementation.
* implementation, or %G_TYPE_INVALID if this backend doesn’t support DTLS.
*
* Since: 2.48
*/
GType
g_tls_backend_get_dtls_client_connection_type (GTlsBackend *backend)
{
return G_TLS_BACKEND_GET_INTERFACE (backend)->get_dtls_client_connection_type ();
GTlsBackendInterface *iface;
g_return_val_if_fail (G_IS_TLS_BACKEND (backend), G_TYPE_INVALID);
iface = G_TLS_BACKEND_GET_INTERFACE (backend);
if (iface->get_dtls_client_connection_type == NULL)
return G_TYPE_INVALID;
return iface->get_dtls_client_connection_type ();
}
/**
......@@ -247,14 +255,22 @@ g_tls_backend_get_dtls_client_connection_type (GTlsBackend *backend)
* Gets the #GType of @backend’s #GDtlsServerConnection implementation.
*
* Returns: the #GType of @backend’s #GDtlsServerConnection
* implementation.
* implementation, or %G_TYPE_INVALID if this backend doesn’t support DTLS.
*
* Since: 2.48
*/
GType
g_tls_backend_get_dtls_server_connection_type (GTlsBackend *backend)
{
return G_TLS_BACKEND_GET_INTERFACE (backend)->get_dtls_server_connection_type ();
GTlsBackendInterface *iface;
g_return_val_if_fail (G_IS_TLS_BACKEND (backend), G_TYPE_INVALID);
iface = G_TLS_BACKEND_GET_INTERFACE (backend);
if (iface->get_dtls_server_connection_type == NULL)
return G_TYPE_INVALID;
return iface->get_dtls_server_connection_type ();
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment