diff lib/cache.c @ 765:d553d14a2565

2006-7-13 Brian Masney <masneyb@gftp.org> * lib/cache.c lib/config_file.c lib/fsp.c lib/ftps.c lib/gftp.h lib/local.c lib/misc.c lib/options.h lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c - started to add some annotations for splint. Fixed a few minor warnings from splint.
author masneyb
date Fri, 14 Jul 2006 00:34:11 +0000
parents 7f54d0c0edbc
children 1808cebed602
line wrap: on
line diff
--- a/lib/cache.c	Fri Jul 07 20:04:42 2006 +0000
+++ b/lib/cache.c	Fri Jul 14 00:34:11 2006 +0000
@@ -36,7 +36,7 @@
 
 
 static int
-gftp_parse_cache_line (gftp_request * request, gftp_cache_entry * centry, 
+gftp_parse_cache_line (gftp_request * request, /*@out@*/ gftp_cache_entry * centry, 
                        char *line)
 {
   char *pos;
@@ -88,7 +88,7 @@
 
 
 static void
-gftp_restore_cache_line (gftp_cache_entry * centry, char *line)
+gftp_restore_cache_line (gftp_cache_entry * centry)
 {
   if (centry->pos1 != NULL)
     *centry->pos1 = '\t';
@@ -102,7 +102,8 @@
 
 
 void
-gftp_generate_cache_description (gftp_request * request, char *description,
+gftp_generate_cache_description (gftp_request * request,
+                                 char *description,
                                  size_t len, int ignore_directory)
 {
   g_snprintf (description, len, "%s://%s@%s:%d%s",
@@ -137,6 +138,7 @@
                                  _("Error: Could not make directory %s: %s\n"),
                                  cachedir, g_strerror (errno));
 
+          g_free (cachedir);
           return (-1);
         }
     }
@@ -156,6 +158,7 @@
   if ((cache_fd = mkstemp (tempstr)) < 0)
     {
       g_free (tempstr);
+      g_free (cachedir);
       if (request != NULL)
         request->logging_function (gftp_logging_error, request,
                                  _("Error: Cannot create temporary file: %s\n"),
@@ -202,6 +205,7 @@
 
   time (&now);
 
+  *description = '\0';
   gftp_generate_cache_description (request, description, sizeof (description),
                                    0);
 
@@ -276,6 +280,7 @@
       return;
     }
 
+  *buf = '\0';
   rbuf = NULL;
   while (gftp_get_line (NULL, &rbuf, buf, sizeof (buf), indexfd) > 0)
     {
@@ -307,6 +312,7 @@
   time (&now);
   if (request != NULL)
     {
+      *description = '\0';
       gftp_generate_cache_description (request, description, sizeof (description),
                                        ignore_directory);
     }
@@ -334,6 +340,7 @@
       return;
     }
 
+  *buf = '\0';
   rbuf = NULL;
   while (gftp_get_line (NULL, &rbuf, buf, sizeof (buf) - 1, indexfd) > 0)
     {
@@ -362,7 +369,7 @@
           /* Make sure we put the tabs back in the line. I do it this way 
              so that I don't have to allocate memory again for each line 
              as we read it */
-          gftp_restore_cache_line (&centry, buf);
+          gftp_restore_cache_line (&centry);
 
           /* Make sure when we call gftp_get_line() that we pass the read size
              as sizeof(buf) - 1 so that we'll have room to put the newline */