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