|
|
1be407 |
diff -up man-db-2.6.3/lib/encodings.c.valgrind-mem man-db-2.6.3/lib/encodings.c
|
|
|
1be407 |
--- man-db-2.6.3/lib/encodings.c.valgrind-mem 2013-04-05 18:19:01.402892699 +0200
|
|
|
1be407 |
+++ man-db-2.6.3/lib/encodings.c 2013-04-05 18:19:01.419892450 +0200
|
|
|
1be407 |
@@ -559,6 +559,7 @@ const char *get_locale_charset (void)
|
|
|
1be407 |
|
|
|
1be407 |
/* Restore LC_CTYPE to its value on entry to this function. */
|
|
|
1be407 |
setlocale (LC_CTYPE, saved_locale);
|
|
|
1be407 |
+ free (saved_locale);
|
|
|
1be407 |
|
|
|
1be407 |
if (charset && *charset)
|
|
|
1be407 |
return get_canonical_charset_name (charset);
|
|
|
1be407 |
@@ -596,9 +597,12 @@ char *find_charset_locale (const char *c
|
|
|
1be407 |
locale = xstrdup("en_US.UTF-8");
|
|
|
1be407 |
if (setlocale (LC_CTYPE, locale)) {
|
|
|
1be407 |
setlocale (LC_CTYPE, saved_locale);
|
|
|
1be407 |
+ free (saved_locale);
|
|
|
1be407 |
return locale;
|
|
|
1be407 |
}
|
|
|
1be407 |
}
|
|
|
1be407 |
+ free (saved_locale);
|
|
|
1be407 |
+ free (locale);
|
|
|
1be407 |
return NULL;
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
@@ -628,6 +632,7 @@ char *find_charset_locale (const char *c
|
|
|
1be407 |
|
|
|
1be407 |
out:
|
|
|
1be407 |
setlocale (LC_CTYPE, saved_locale);
|
|
|
1be407 |
+ free (saved_locale);
|
|
|
1be407 |
fclose (supported);
|
|
|
1be407 |
return locale;
|
|
|
1be407 |
}
|
|
|
1be407 |
diff -up man-db-2.6.3/src/check_mandirs.c.valgrind-mem man-db-2.6.3/src/check_mandirs.c
|
|
|
1be407 |
--- man-db-2.6.3/src/check_mandirs.c.valgrind-mem 2013-04-05 18:19:01.415892509 +0200
|
|
|
1be407 |
+++ man-db-2.6.3/src/check_mandirs.c 2013-04-05 18:19:01.420892435 +0200
|
|
|
1be407 |
@@ -442,6 +442,7 @@ static int testmandirs (const char *path
|
|
|
1be407 |
|
|
|
1be407 |
if (chdir (path) != 0) {
|
|
|
1be407 |
error (0, errno, _("can't change to directory %s"), path);
|
|
|
1be407 |
+ closedir (dir);
|
|
|
1be407 |
return 0;
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
@@ -479,11 +480,13 @@ static int testmandirs (const char *path
|
|
|
1be407 |
if (errno == EACCES || errno == EROFS) {
|
|
|
1be407 |
debug ("database %s is read-only\n",
|
|
|
1be407 |
database);
|
|
|
1be407 |
+ closedir (dir);
|
|
|
1be407 |
return 0;
|
|
|
1be407 |
} else {
|
|
|
1be407 |
error (0, errno,
|
|
|
1be407 |
_("can't create index cache %s"),
|
|
|
1be407 |
database);
|
|
|
1be407 |
+ closedir (dir);
|
|
|
1be407 |
return -errno;
|
|
|
1be407 |
}
|
|
|
1be407 |
}
|
|
|
1be407 |
@@ -496,6 +499,7 @@ static int testmandirs (const char *path
|
|
|
1be407 |
|
|
|
1be407 |
if (!dbf) {
|
|
|
1be407 |
gripe_rwopen_failed ();
|
|
|
1be407 |
+ closedir (dir);
|
|
|
1be407 |
return 0;
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
diff -up man-db-2.6.3/src/manconv_client.c.valgrind-mem man-db-2.6.3/src/manconv_client.c
|
|
|
1be407 |
--- man-db-2.6.3/src/manconv_client.c.valgrind-mem 2011-01-04 04:04:50.000000000 +0100
|
|
|
1be407 |
+++ man-db-2.6.3/src/manconv_client.c 2013-04-05 18:40:45.360739910 +0200
|
|
|
1be407 |
@@ -111,8 +111,10 @@ void add_manconv (pipeline *p, const cha
|
|
|
1be407 |
char *name;
|
|
|
1be407 |
pipecmd *cmd;
|
|
|
1be407 |
|
|
|
1be407 |
- if (STREQ (source, "UTF-8") && STREQ (target, "UTF-8"))
|
|
|
1be407 |
+ if (STREQ (source, "UTF-8") && STREQ (target, "UTF-8")) {
|
|
|
1be407 |
+ free (codes);
|
|
|
1be407 |
return;
|
|
|
1be407 |
+ }
|
|
|
1be407 |
|
|
|
1be407 |
/* informational only; no shell quoting concerns */
|
|
|
1be407 |
name = appendstr (NULL, MANCONV, " -f ", NULL);
|
|
|
1be407 |
diff -up man-db-2.6.3/src/man.c.valgrind-mem man-db-2.6.3/src/man.c
|
|
|
1be407 |
--- man-db-2.6.3/src/man.c.valgrind-mem 2013-04-05 18:19:01.408892611 +0200
|
|
|
1be407 |
+++ man-db-2.6.3/src/man.c 2013-04-05 18:40:56.233580113 +0200
|
|
|
1be407 |
@@ -188,7 +188,7 @@ static char *manpathlist[MAXDIRS];
|
|
|
1be407 |
/* globals */
|
|
|
1be407 |
int quiet = 1;
|
|
|
1be407 |
char *program_name;
|
|
|
1be407 |
-char *database;
|
|
|
1be407 |
+char *database = NULL;
|
|
|
1be407 |
MYDBM_FILE dbf;
|
|
|
1be407 |
extern const char *extension; /* for globbing.c */
|
|
|
1be407 |
extern char *user_config_file; /* defined in manp.c */
|
|
|
1be407 |
@@ -207,7 +207,7 @@ static char *internal_locale, *multiple_
|
|
|
1be407 |
static const char *prompt_string;
|
|
|
1be407 |
static char *less;
|
|
|
1be407 |
static const char *std_sections[] = STD_SECTIONS;
|
|
|
1be407 |
-static char *manp;
|
|
|
1be407 |
+static char *manp = NULL;
|
|
|
1be407 |
static const char *external;
|
|
|
1be407 |
static struct hashtable *db_hash = NULL;
|
|
|
1be407 |
|
|
|
1be407 |
@@ -950,7 +950,7 @@ static int local_man_loop (const char *a
|
|
|
1be407 |
|
|
|
1be407 |
if (directory_on_path (argv_dir)) {
|
|
|
1be407 |
char *argv_base = base_name (argv);
|
|
|
1be407 |
- char *new_manp;
|
|
|
1be407 |
+ char *new_manp, *nm;
|
|
|
1be407 |
char **old_manpathlist, **mp;
|
|
|
1be407 |
|
|
|
1be407 |
debug ("recalculating manpath for executable "
|
|
|
1be407 |
@@ -962,7 +962,9 @@ static int local_man_loop (const char *a
|
|
|
1be407 |
"executable\n");
|
|
|
1be407 |
goto executable_out;
|
|
|
1be407 |
}
|
|
|
1be407 |
- new_manp = locale_manpath (new_manp);
|
|
|
1be407 |
+ nm = locale_manpath (new_manp);
|
|
|
1be407 |
+ free (new_manp);
|
|
|
1be407 |
+ new_manp = nm;
|
|
|
1be407 |
|
|
|
1be407 |
old_manpathlist = XNMALLOC (MAXDIRS, char *);
|
|
|
1be407 |
memcpy (old_manpathlist, manpathlist,
|
|
|
1be407 |
@@ -1167,14 +1169,21 @@ int main (int argc, char *argv[])
|
|
|
1be407 |
manp = get_manpath ("");
|
|
|
1be407 |
printf ("%s\n", manp);
|
|
|
1be407 |
exit (OK);
|
|
|
1be407 |
- } else
|
|
|
1be407 |
+ } else {
|
|
|
1be407 |
+ free (cwd);
|
|
|
1be407 |
+ free (internal_locale);
|
|
|
1be407 |
+ free (program_name);
|
|
|
1be407 |
gripe_no_name (NULL);
|
|
|
1be407 |
+ }
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
section_list = get_section_list ();
|
|
|
1be407 |
|
|
|
1be407 |
- if (manp == NULL)
|
|
|
1be407 |
- manp = locale_manpath (get_manpath (alt_system_name));
|
|
|
1be407 |
+ if (manp == NULL) {
|
|
|
1be407 |
+ char *mp = get_manpath (alt_system_name);
|
|
|
1be407 |
+ manp = locale_manpath (mp);
|
|
|
1be407 |
+ free (mp);
|
|
|
1be407 |
+ }
|
|
|
1be407 |
else
|
|
|
1be407 |
free (get_manpath (NULL));
|
|
|
1be407 |
|
|
|
1be407 |
@@ -1350,6 +1359,14 @@ int main (int argc, char *argv[])
|
|
|
1be407 |
if (cwd[0])
|
|
|
1be407 |
chdir (cwd);
|
|
|
1be407 |
|
|
|
1be407 |
+ if (database) {
|
|
|
1be407 |
+ free (database);
|
|
|
1be407 |
+ database = NULL;
|
|
|
1be407 |
+ }
|
|
|
1be407 |
+ if (manp) {
|
|
|
1be407 |
+ free (manp);
|
|
|
1be407 |
+ manp = NULL;
|
|
|
1be407 |
+ }
|
|
|
1be407 |
free_pathlist (manpathlist);
|
|
|
1be407 |
free (cwd);
|
|
|
1be407 |
free (internal_locale);
|
|
|
1be407 |
@@ -1810,6 +1827,9 @@ static pipeline *make_roff_command (cons
|
|
|
1be407 |
pipeline_command (p, cmd);
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
+ /* free pp_string */
|
|
|
1be407 |
+ get_preprocessors_from_file(NULL);
|
|
|
1be407 |
+
|
|
|
1be407 |
free (page_encoding);
|
|
|
1be407 |
return p;
|
|
|
1be407 |
}
|
|
|
1be407 |
@@ -2327,6 +2347,7 @@ static void format_display (pipeline *de
|
|
|
1be407 |
htmldir);
|
|
|
1be407 |
free (htmlfile);
|
|
|
1be407 |
free (htmldir);
|
|
|
1be407 |
+ free (old_cwd);
|
|
|
1be407 |
} else
|
|
|
1be407 |
#endif /* TROFF_IS_GROFF */
|
|
|
1be407 |
/* TODO: check format_cmd status too? */
|
|
|
1be407 |
@@ -2498,6 +2519,7 @@ static int display (const char *dir, con
|
|
|
1be407 |
free (name);
|
|
|
1be407 |
free_locale_bits (&bits);
|
|
|
1be407 |
}
|
|
|
1be407 |
+ free (page_lang);
|
|
|
1be407 |
}
|
|
|
1be407 |
#endif /* TROFF_IS_GROFF */
|
|
|
1be407 |
|
|
|
1be407 |
@@ -2564,6 +2586,7 @@ static int display (const char *dir, con
|
|
|
1be407 |
if (prompt && do_prompt (title)) {
|
|
|
1be407 |
pipeline_free (format_cmd);
|
|
|
1be407 |
pipeline_free (decomp);
|
|
|
1be407 |
+ free (formatted_encoding);
|
|
|
1be407 |
return 0;
|
|
|
1be407 |
}
|
|
|
1be407 |
drop_effective_privs ();
|
|
|
1be407 |
@@ -2690,6 +2713,7 @@ static int display (const char *dir, con
|
|
|
1be407 |
if (prompt && do_prompt (title)) {
|
|
|
1be407 |
pipeline_free (format_cmd);
|
|
|
1be407 |
pipeline_free (decomp);
|
|
|
1be407 |
+ free (formatted_encoding);
|
|
|
1be407 |
if (local_man_file)
|
|
|
1be407 |
return 1;
|
|
|
1be407 |
else
|
|
|
1be407 |
@@ -2741,6 +2765,8 @@ static int display (const char *dir, con
|
|
|
1be407 |
}
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
+ free (formatted_encoding);
|
|
|
1be407 |
+
|
|
|
1be407 |
pipeline_free (format_cmd);
|
|
|
1be407 |
pipeline_free (decomp);
|
|
|
1be407 |
|
|
|
1be407 |
@@ -2802,6 +2828,7 @@ static char *find_cat_file (const char *
|
|
|
1be407 |
*tmp = 0;
|
|
|
1be407 |
if (is_directory (cat_dir)) {
|
|
|
1be407 |
debug ("will try cat file %s\n", cat_file);
|
|
|
1be407 |
+ free (cat_dir);
|
|
|
1be407 |
return cat_file;
|
|
|
1be407 |
} else
|
|
|
1be407 |
debug ("cat dir %s does not exist\n", cat_dir);
|
|
|
1be407 |
@@ -3272,6 +3299,7 @@ static int try_section (const char *path
|
|
|
1be407 |
}
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
+ int f;
|
|
|
1be407 |
for (np = names; np && *np; np++) {
|
|
|
1be407 |
struct mandata *info = infoalloc ();
|
|
|
1be407 |
char *info_buffer = filename_info (*np, info, name);
|
|
|
1be407 |
@@ -3300,8 +3328,15 @@ static int try_section (const char *path
|
|
|
1be407 |
else
|
|
|
1be407 |
info->id = SO_MAN;
|
|
|
1be407 |
|
|
|
1be407 |
- found += add_candidate (cand_head, CANDIDATE_FILESYSTEM,
|
|
|
1be407 |
+ f = add_candidate (cand_head, CANDIDATE_FILESYSTEM,
|
|
|
1be407 |
cat, name, path, ult, info);
|
|
|
1be407 |
+ found += f;
|
|
|
1be407 |
+ /* Free info and info_buffer if it wasn't added to the candidates. */
|
|
|
1be407 |
+ if (f == 0) {
|
|
|
1be407 |
+ free (info_buffer);
|
|
|
1be407 |
+ info->addr = NULL;
|
|
|
1be407 |
+ free_mandata_struct (info);
|
|
|
1be407 |
+ }
|
|
|
1be407 |
/* Don't free info and info_buffer here. */
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
@@ -3319,9 +3354,13 @@ static int display_filesystem (struct ca
|
|
|
1be407 |
char *title = appendstr (NULL, candp->source->name,
|
|
|
1be407 |
"(", candp->source->ext, ")", NULL);
|
|
|
1be407 |
if (candp->cat) {
|
|
|
1be407 |
- if (troff || want_encoding || recode)
|
|
|
1be407 |
+ if (troff || want_encoding || recode) {
|
|
|
1be407 |
+ free (title);
|
|
|
1be407 |
return 0;
|
|
|
1be407 |
- return display (candp->path, NULL, filename, title, NULL);
|
|
|
1be407 |
+ }
|
|
|
1be407 |
+ int r = display (candp->path, NULL, filename, title, NULL);
|
|
|
1be407 |
+ free (title);
|
|
|
1be407 |
+ return r;
|
|
|
1be407 |
} else {
|
|
|
1be407 |
const char *man_file;
|
|
|
1be407 |
char *cat_file;
|
|
|
1be407 |
@@ -3344,6 +3383,7 @@ static int display_filesystem (struct ca
|
|
|
1be407 |
free (lang);
|
|
|
1be407 |
lang = NULL;
|
|
|
1be407 |
free (title);
|
|
|
1be407 |
+ free (filename);
|
|
|
1be407 |
|
|
|
1be407 |
return found;
|
|
|
1be407 |
}
|
|
|
1be407 |
@@ -3571,6 +3611,10 @@ static int try_db (const char *manpath,
|
|
|
1be407 |
/* find out where our db for this manpath should be */
|
|
|
1be407 |
|
|
|
1be407 |
catpath = get_catpath (manpath, global_manpath ? SYSTEM_CAT : USER_CAT);
|
|
|
1be407 |
+ if (database) {
|
|
|
1be407 |
+ free (database);
|
|
|
1be407 |
+ database = NULL;
|
|
|
1be407 |
+ }
|
|
|
1be407 |
if (catpath) {
|
|
|
1be407 |
database = mkdbname (catpath);
|
|
|
1be407 |
free (catpath);
|
|
|
1be407 |
@@ -3942,7 +3986,7 @@ static int man (const char *name, int *f
|
|
|
1be407 |
|
|
|
1be407 |
for (cand = candidates; cand; cand = candnext) {
|
|
|
1be407 |
candnext = cand->next;
|
|
|
1be407 |
- free (cand);
|
|
|
1be407 |
+ free_candidate (cand);
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
return *found ? OK : NOT_FOUND;
|
|
|
1be407 |
diff -up man-db-2.6.3/src/mandb.c.valgrind-mem man-db-2.6.3/src/mandb.c
|
|
|
1be407 |
--- man-db-2.6.3/src/mandb.c.valgrind-mem 2012-02-21 12:15:11.000000000 +0100
|
|
|
1be407 |
+++ man-db-2.6.3/src/mandb.c 2013-04-05 18:19:01.425892362 +0200
|
|
|
1be407 |
@@ -247,7 +247,7 @@ static int xcopy (const char *from, cons
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
while (!feof (ifp) && !ferror (ifp)) {
|
|
|
1be407 |
- char buf[32 * 1024];
|
|
|
1be407 |
+ char buf[9 * 1024];
|
|
|
1be407 |
size_t in = fread (buf, 1, sizeof (buf), ifp);
|
|
|
1be407 |
if (in > 0) {
|
|
|
1be407 |
if (fwrite (buf, 1, in, ofp) == 0 && ferror (ofp)) {
|
|
|
1be407 |
diff -up man-db-2.6.3/src/manp.c.valgrind-mem man-db-2.6.3/src/manp.c
|
|
|
1be407 |
--- man-db-2.6.3/src/manp.c.valgrind-mem 2013-04-05 18:19:01.412892553 +0200
|
|
|
1be407 |
+++ man-db-2.6.3/src/manp.c 2013-04-05 18:19:01.428892318 +0200
|
|
|
1be407 |
@@ -504,6 +504,7 @@ static char *get_nls_manpath (const char
|
|
|
1be407 |
|
|
|
1be407 |
closedir (mandir);
|
|
|
1be407 |
}
|
|
|
1be407 |
+ free (manpathlist_copy);
|
|
|
1be407 |
|
|
|
1be407 |
free_locale_bits (&lbits);
|
|
|
1be407 |
return manpath;
|
|
|
1be407 |
@@ -567,6 +568,7 @@ char *add_nls_manpaths (char *manpathlis
|
|
|
1be407 |
free (locale_manpath);
|
|
|
1be407 |
}
|
|
|
1be407 |
}
|
|
|
1be407 |
+ free (locales_copy);
|
|
|
1be407 |
|
|
|
1be407 |
/* Always try untranslated pages as a last resort. */
|
|
|
1be407 |
locale_manpath = get_nls_manpath (manpathlist, "C");
|
|
|
1be407 |
@@ -820,6 +822,11 @@ next:
|
|
|
1be407 |
free (buf);
|
|
|
1be407 |
buf = NULL;
|
|
|
1be407 |
}
|
|
|
1be407 |
+
|
|
|
1be407 |
+ if (buf) {
|
|
|
1be407 |
+ free (buf);
|
|
|
1be407 |
+ buf = NULL;
|
|
|
1be407 |
+ }
|
|
|
1be407 |
}
|
|
|
1be407 |
|
|
|
1be407 |
static void free_config_file (void *unused ATTRIBUTE_UNUSED)
|
|
|
1be407 |
diff -up man-db-2.6.3/src/whatis.c.valgrind-mem man-db-2.6.3/src/whatis.c
|
|
|
1be407 |
--- man-db-2.6.3/src/whatis.c.valgrind-mem 2012-06-18 12:23:37.000000000 +0200
|
|
|
1be407 |
+++ man-db-2.6.3/src/whatis.c 2013-04-05 18:19:01.429892304 +0200
|
|
|
1be407 |
@@ -501,7 +501,7 @@ static inline int do_whatis_section (con
|
|
|
1be407 |
|
|
|
1be407 |
static int suitable_manpath (const char *manpath, const char *page_dir)
|
|
|
1be407 |
{
|
|
|
1be407 |
- char *page_manp;
|
|
|
1be407 |
+ char *page_manp, *pm;
|
|
|
1be407 |
char *page_manpathlist[MAXDIRS], **mp;
|
|
|
1be407 |
int ret;
|
|
|
1be407 |
|
|
|
1be407 |
@@ -510,7 +510,9 @@ static int suitable_manpath (const char
|
|
|
1be407 |
free (page_manp);
|
|
|
1be407 |
return 0;
|
|
|
1be407 |
}
|
|
|
1be407 |
- page_manp = locale_manpath (page_manp);
|
|
|
1be407 |
+ pm = locale_manpath (page_manp);
|
|
|
1be407 |
+ free (page_manp);
|
|
|
1be407 |
+ page_manp = pm;
|
|
|
1be407 |
create_pathlist (page_manp, page_manpathlist);
|
|
|
1be407 |
|
|
|
1be407 |
ret = 0;
|
|
|
1be407 |
@@ -554,6 +556,7 @@ static void do_whatis (const char * cons
|
|
|
1be407 |
debug ("%s not on manpath for %s\n",
|
|
|
1be407 |
manpath, page);
|
|
|
1be407 |
free (page_dir);
|
|
|
1be407 |
+ free (page);
|
|
|
1be407 |
continue;
|
|
|
1be407 |
}
|
|
|
1be407 |
}
|