1*4882a593SmuzhiyunBorrowed from the curlftpfs_0.9.2-5 Debian package. 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunFix a memory leak when cache is disabled. Closes: #614347. 4*4882a593Smuzhiyundiff -ur curlftpfs-0.9.2/cache.c curlftpfs-0.9.2-olexat/cache.c 5*4882a593Smuzhiyun--- curlftpfs-0.9.2/cache.c 2008-04-30 01:03:09.000000000 +0200 6*4882a593Smuzhiyun+++ curlftpfs-0.9.2-olexat/cache.c 2011-02-04 16:43:05.000000000 +0100 7*4882a593Smuzhiyun@@ -25,7 +25,7 @@ 8*4882a593Smuzhiyun time_t last_cleaned; 9*4882a593Smuzhiyun }; 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun-static struct cache cache; 12*4882a593Smuzhiyun+struct cache cache; 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun struct node { 15*4882a593Smuzhiyun struct stat stat; 16*4882a593Smuzhiyundiff -ur curlftpfs-0.9.2/ftpfs-ls.c curlftpfs-0.9.2-olexat/ftpfs-ls.c 17*4882a593Smuzhiyun--- curlftpfs-0.9.2/ftpfs-ls.c 2008-04-23 12:55:41.000000000 +0200 18*4882a593Smuzhiyun+++ curlftpfs-0.9.2-olexat/ftpfs-ls.c 2011-02-07 17:23:37.000000000 +0100 19*4882a593Smuzhiyun@@ -25,6 +25,13 @@ 20*4882a593Smuzhiyun #include "charset_utils.h" 21*4882a593Smuzhiyun #include "ftpfs-ls.h" 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun+struct cache { 24*4882a593Smuzhiyun+ int on; 25*4882a593Smuzhiyun+ char incomplete[]; 26*4882a593Smuzhiyun+}; 27*4882a593Smuzhiyun+ 28*4882a593Smuzhiyun+extern struct cache cache; 29*4882a593Smuzhiyun+ 30*4882a593Smuzhiyun static int parse_dir_unix(const char *line, 31*4882a593Smuzhiyun struct stat *sbuf, 32*4882a593Smuzhiyun char *file, 33*4882a593Smuzhiyun@@ -243,8 +256,10 @@ 34*4882a593Smuzhiyun reallink = g_strdup(link); 35*4882a593Smuzhiyun } 36*4882a593Smuzhiyun int linksize = strlen(reallink); 37*4882a593Smuzhiyun- cache_add_link(full_path, reallink, linksize+1); 38*4882a593Smuzhiyun- DEBUG(1, "cache_add_link: %s %s\n", full_path, reallink); 39*4882a593Smuzhiyun+ if (cache.on) { 40*4882a593Smuzhiyun+ cache_add_link(full_path, reallink, linksize+1); 41*4882a593Smuzhiyun+ DEBUG(1, "cache_add_link: %s %s\n", full_path, reallink); 42*4882a593Smuzhiyun+ } 43*4882a593Smuzhiyun if (linkbuf && linklen) { 44*4882a593Smuzhiyun if (linksize > linklen) linksize = linklen - 1; 45*4882a593Smuzhiyun strncpy(linkbuf, reallink, linksize); 46*4882a593Smuzhiyun@@ -257,8 +272,10 @@ 47*4882a593Smuzhiyun DEBUG(1, "filler: %s\n", file); 48*4882a593Smuzhiyun filler(h, file, &stat_buf); 49*4882a593Smuzhiyun } else { 50*4882a593Smuzhiyun- DEBUG(1, "cache_add_attr: %s\n", full_path); 51*4882a593Smuzhiyun- cache_add_attr(full_path, &stat_buf); 52*4882a593Smuzhiyun+ if (cache.on) { 53*4882a593Smuzhiyun+ DEBUG(1, "cache_add_attr: %s\n", full_path); 54*4882a593Smuzhiyun+ cache_add_attr(full_path, &stat_buf); 55*4882a593Smuzhiyun+ } 56*4882a593Smuzhiyun } 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun DEBUG(2, "comparing %s %s\n", name, file); 59*4882a593Smuzhiyun 60