54 lines
1.9 KiB
Text
54 lines
1.9 KiB
Text
- Fix a memory leak when cache is disabled. Debian #614347
|
|
- Fix format string:
|
|
[ftpfs-ls.c:57]: (warning) %lu in format string (no. 2) requires 'unsigned long *' but the argument type is 'long *'.
|
|
--- ftpfs-ls.c.orig Wed Apr 23 12:55:41 2008
|
|
+++ ftpfs-ls.c Mon Dec 16 10:44:08 2013
|
|
@@ -25,6 +25,13 @@
|
|
#include "charset_utils.h"
|
|
#include "ftpfs-ls.h"
|
|
|
|
+struct cache {
|
|
+ int on;
|
|
+ char incomplete[];
|
|
+};
|
|
+
|
|
+extern struct cache cache;
|
|
+
|
|
static int parse_dir_unix(const char *line,
|
|
struct stat *sbuf,
|
|
char *file,
|
|
@@ -49,7 +56,7 @@ static int parse_dir_unix(const char *line,
|
|
#define SPACES "%*[ \t]"
|
|
res = sscanf(line,
|
|
"%11s"
|
|
- "%lu" SPACES
|
|
+ "%ld" SPACES
|
|
"%32s" SPACES
|
|
"%32s" SPACES
|
|
"%llu" SPACES
|
|
@@ -243,8 +250,10 @@ int parse_dir(const char* list, const char* dir,
|
|
reallink = g_strdup(link);
|
|
}
|
|
int linksize = strlen(reallink);
|
|
- cache_add_link(full_path, reallink, linksize+1);
|
|
- DEBUG(1, "cache_add_link: %s %s\n", full_path, reallink);
|
|
+ if (cache.on) {
|
|
+ cache_add_link(full_path, reallink, linksize+1);
|
|
+ DEBUG(1, "cache_add_link: %s %s\n", full_path, reallink);
|
|
+ }
|
|
if (linkbuf && linklen) {
|
|
if (linksize > linklen) linksize = linklen - 1;
|
|
strncpy(linkbuf, reallink, linksize);
|
|
@@ -257,8 +266,10 @@ int parse_dir(const char* list, const char* dir,
|
|
DEBUG(1, "filler: %s\n", file);
|
|
filler(h, file, &stat_buf);
|
|
} else {
|
|
- DEBUG(1, "cache_add_attr: %s\n", full_path);
|
|
- cache_add_attr(full_path, &stat_buf);
|
|
+ if (cache.on) {
|
|
+ DEBUG(1, "cache_add_attr: %s\n", full_path);
|
|
+ cache_add_attr(full_path, &stat_buf);
|
|
+ }
|
|
}
|
|
|
|
DEBUG(2, "comparing %s %s\n", name, file);
|