Merge branch 'liboping-1.2'
[liboping.git] / src / liboping.c
index acbc715..6950103 100644 (file)
@@ -1007,6 +1007,8 @@ static void ping_free (pinghost_t *ph)
  */
 const char *ping_get_error (pingobj_t *obj)
 {
+       if (obj == NULL)
+               return (NULL);
        return (obj->errmsg);
 }
 
@@ -1031,6 +1033,9 @@ void ping_destroy (pingobj_t *obj)
        pinghost_t *current;
        pinghost_t *next;
 
+       if (obj == NULL)
+               return;
+
        current = obj->head;
        next = NULL;
 
@@ -1059,6 +1064,9 @@ int ping_setopt (pingobj_t *obj, int option, void *value)
 {
        int ret = 0;
 
+       if ((obj == NULL) || (value == NULL))
+               return (-1);
+
        switch (option)
        {
                case PING_OPT_TIMEOUT:
@@ -1206,6 +1214,9 @@ int ping_send (pingobj_t *obj)
 {
        int ret;
 
+       if (obj == NULL)
+               return (-1);
+
        if (ping_send_all (obj) < 0)
                return (-1);
 
@@ -1236,6 +1247,9 @@ int ping_host_add (pingobj_t *obj, const char *host)
        struct addrinfo *ai_list, *ai_ptr;
        int              ai_return;
 
+       if ((obj == NULL) || (host == NULL))
+               return (-1);
+
        dprintf ("host = %s\n", host);
 
        if (ping_host_search (obj->head, host) != NULL)
@@ -1466,6 +1480,9 @@ int ping_host_remove (pingobj_t *obj, const char *host)
 {
        pinghost_t *pre, *cur;
 
+       if ((obj == NULL) || (host == NULL))
+               return (-1);
+
        pre = NULL;
        cur = obj->head;
 
@@ -1496,11 +1513,15 @@ int ping_host_remove (pingobj_t *obj, const char *host)
 
 pingobj_iter_t *ping_iterator_get (pingobj_t *obj)
 {
+       if (obj == NULL)
+               return (NULL);
        return ((pingobj_iter_t *) obj->head);
 }
 
 pingobj_iter_t *ping_iterator_next (pingobj_iter_t *iter)
 {
+       if (iter == NULL)
+               return (NULL);
        return ((pingobj_iter_t *) iter->next);
 }
 
@@ -1511,6 +1532,9 @@ int ping_iterator_get_info (pingobj_iter_t *iter, int info,
 
        size_t orig_buffer_len = *buffer_len;
 
+       if ((iter == NULL) || (buffer == NULL) || (buffer_len == NULL))
+               return (-1);
+
        switch (info)
        {
                case PING_INFO_USERNAME:
@@ -1630,10 +1654,14 @@ int ping_iterator_get_info (pingobj_iter_t *iter, int info,
 
 void *ping_iterator_get_context (pingobj_iter_t *iter)
 {
+       if (iter == NULL)
+               return (NULL);
        return (iter->context);
 }
 
 void ping_iterator_set_context (pingobj_iter_t *iter, void *context)
 {
+       if (iter == NULL)
+               return;
        iter->context = context;
 }