Check the return value of hashmap_first()
authorRobert James Kaes <rjkaes@users.sourceforge.net>
Fri, 26 Apr 2002 16:50:55 +0000 (16:50 +0000)
committerRobert James Kaes <rjkaes@users.sourceforge.net>
Fri, 26 Apr 2002 16:50:55 +0000 (16:50 +0000)
ChangeLog
src/log.c

index 5e13517355c26a8a60261afc733a909bb58e3f14..f482c5aebd160bc51573c92155ec7e088bc48ab6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2002-04-26  Robert James Kaes  <rjkaes@flarenet.com>
 
+       * src/log.c (send_stored_logs): Check the return value of
+       hashmap_first() since it could be -1, indicating an empty hashmap.
+
        * src/reqs.c (process_client_headers):
        (process_server_headers): Test the return value of hashmap_first()
        since the hashmap could be empty (returning a -1 via hashmap_first.)
index 5ae6ded1a205ffa55d25a7b4e68fc0fad0f155e5..9577e5f4a7300e3dabfd19660786f6f92ad5d3b6 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1,4 +1,4 @@
-/* $Id: log.c,v 1.18 2002-04-25 18:56:43 rjkaes Exp $
+/* $Id: log.c,v 1.19 2002-04-26 16:50:55 rjkaes Exp $
  *
  * Logs the various messages which tinyproxy produces to either a log file or
  * the syslog daemon. Not much to it...
@@ -159,13 +159,14 @@ send_stored_logs(void)
        char *level;
        char *string;
        
-       for (iter = hashmap_first(log_message_storage);
-            iter != hashmap_is_end(log_message_storage, iter);
-            ++iter) {
-               hashmap_return_entry(log_message_storage,
-                                    iter,
-                                    &string,
-                                    (void **)&level);
+       iter = hashmap_first(log_message_storage);
+       if (iter >= 0) {
+               for ( ; iter != hashmap_is_end(log_message_storage, iter); ++iter) {
+                       hashmap_return_entry(log_message_storage,
+                                            iter,
+                                            &string,
+                                            (void **)&level);
+               }
        }
 
        hashmap_delete(log_message_storage);