From e47f5a979764c17d59432f2b7b35a89798b1d2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Tue, 30 Sep 2014 23:10:33 -0400 Subject: Move pre-conditions to the synchronous functions --- libgupnp-igd/gupnp-simple-igd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libgupnp-igd/gupnp-simple-igd.c b/libgupnp-igd/gupnp-simple-igd.c index efc231a..775c4d3 100644 --- a/libgupnp-igd/gupnp-simple-igd.c +++ b/libgupnp-igd/gupnp-simple-igd.c @@ -923,6 +923,9 @@ gupnp_simple_igd_add_port (GUPnPSimpleIgd *self, GUPnPSimpleIgdClass *klass = GUPNP_SIMPLE_IGD_GET_CLASS (self); g_return_if_fail (klass->add_port); + g_return_if_fail (protocol && local_ip); + g_return_if_fail (local_port > 0); + g_return_if_fail (!strcmp (protocol, "UDP") || !strcmp (protocol, "TCP")); klass->add_port (self, protocol, external_port, local_ip, local_port, lease_duration, description); @@ -936,8 +939,6 @@ gupnp_simple_igd_remove_port_real (GUPnPSimpleIgd *self, struct Mapping *mapping = NULL; guint i; - g_return_if_fail (protocol); - for (i = 0; i < self->priv->mappings->len; i++) { struct Mapping *tmpmapping = g_ptr_array_index (self->priv->mappings, i); @@ -976,6 +977,9 @@ gupnp_simple_igd_remove_port (GUPnPSimpleIgd *self, { GUPnPSimpleIgdClass *klass = GUPNP_SIMPLE_IGD_GET_CLASS (self); + g_return_if_fail (protocol); + g_return_if_fail (external_port <= 65535); + g_return_if_fail (klass->remove_port); klass->remove_port (self, protocol, external_port); -- cgit v1.2.1