|
|
914926 |
diff --git a/gnulib/lib/getopt.c b/gnulib/lib/getopt.c
|
|
|
914926 |
index 7d950af..fa30f13 100644
|
|
|
914926 |
--- a/gnulib/lib/getopt.c
|
|
|
914926 |
+++ b/gnulib/lib/getopt.c
|
|
|
914926 |
@@ -487,7 +487,15 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
|
|
914926 |
const struct option *p;
|
|
|
914926 |
struct option_list *next;
|
|
|
914926 |
} *ambig_list = NULL;
|
|
|
914926 |
+# define free_option_list(l) \
|
|
|
914926 |
+ while (l != NULL) \
|
|
|
914926 |
+ { \
|
|
|
914926 |
+ struct option_list *pn = l->next; \
|
|
|
914926 |
+ free (l); \
|
|
|
914926 |
+ l = pn; \
|
|
|
914926 |
+ }
|
|
|
914926 |
int exact = 0;
|
|
|
914926 |
+ int ambig = 0;
|
|
|
914926 |
int indfound = -1;
|
|
|
914926 |
int option_index;
|
|
|
914926 |
|
|
|
914926 |
@@ -521,15 +529,25 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
|
|
914926 |
{
|
|
|
914926 |
/* Second or later nonexact match found. */
|
|
|
914926 |
struct option_list *newp = malloc (sizeof (*newp));
|
|
|
914926 |
- newp->p = p;
|
|
|
914926 |
- newp->next = ambig_list;
|
|
|
914926 |
- ambig_list = newp;
|
|
|
914926 |
+ if (newp == NULL)
|
|
|
914926 |
+ {
|
|
|
914926 |
+ ambig = 1; /* Use simpler fallback message. */
|
|
|
914926 |
+ free_option_list (ambig_list);
|
|
|
914926 |
+ ambig_list = NULL;
|
|
|
914926 |
+ break;
|
|
|
914926 |
+ }
|
|
|
914926 |
+ else
|
|
|
914926 |
+ {
|
|
|
914926 |
+ newp->p = p;
|
|
|
914926 |
+ newp->next = ambig_list;
|
|
|
914926 |
+ ambig_list = newp;
|
|
|
914926 |
+ }
|
|
|
914926 |
}
|
|
|
914926 |
}
|
|
|
914926 |
|
|
|
914926 |
- if (ambig_list != NULL && !exact)
|
|
|
914926 |
+ if ((ambig || ambig_list) && !exact)
|
|
|
914926 |
{
|
|
|
914926 |
- if (print_errors)
|
|
|
914926 |
+ if (print_errors && ambig_list)
|
|
|
914926 |
{
|
|
|
914926 |
struct option_list first;
|
|
|
914926 |
first.p = pfound;
|
|
|
914926 |
@@ -585,18 +603,20 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
|
|
914926 |
fputc ('\n', stderr);
|
|
|
914926 |
#endif
|
|
|
914926 |
}
|
|
|
914926 |
+ else if (print_errors && ambig)
|
|
|
914926 |
+ {
|
|
|
914926 |
+ fprintf (stderr,
|
|
|
914926 |
+ _("%s: option '%s' is ambiguous\n"),
|
|
|
914926 |
+ argv[0], argv[d->optind]);
|
|
|
914926 |
+ }
|
|
|
914926 |
d->__nextchar += strlen (d->__nextchar);
|
|
|
914926 |
d->optind++;
|
|
|
914926 |
d->optopt = 0;
|
|
|
914926 |
+ free_option_list (ambig_list);
|
|
|
914926 |
return '?';
|
|
|
914926 |
}
|
|
|
914926 |
|
|
|
914926 |
- while (ambig_list != NULL)
|
|
|
914926 |
- {
|
|
|
914926 |
- struct option_list *pn = ambig_list->next;
|
|
|
914926 |
- free (ambig_list);
|
|
|
914926 |
- ambig_list = pn;
|
|
|
914926 |
- }
|
|
|
914926 |
+ free_option_list (ambig_list);
|
|
|
914926 |
|
|
|
914926 |
if (pfound != NULL)
|
|
|
914926 |
{
|
|
|
914926 |
diff --git a/lib/decompress.c b/lib/decompress.c
|
|
|
914926 |
index a176a9d..2be532f 100644
|
|
|
914926 |
--- a/lib/decompress.c
|
|
|
914926 |
+++ b/lib/decompress.c
|
|
|
914926 |
@@ -48,11 +48,18 @@
|
|
|
914926 |
static void decompress_zlib (void *data ATTRIBUTE_UNUSED)
|
|
|
914926 |
{
|
|
|
914926 |
gzFile zlibfile;
|
|
|
914926 |
+ int fd;
|
|
|
914926 |
|
|
|
914926 |
- zlibfile = gzdopen (dup (STDIN_FILENO), "r");
|
|
|
914926 |
- if (!zlibfile)
|
|
|
914926 |
+ fd = dup (STDIN_FILENO);
|
|
|
914926 |
+ if (fd < 0)
|
|
|
914926 |
return;
|
|
|
914926 |
|
|
|
914926 |
+ zlibfile = gzdopen (fd, "r");
|
|
|
914926 |
+ if (!zlibfile) {
|
|
|
914926 |
+ close (fd);
|
|
|
914926 |
+ return;
|
|
|
914926 |
+ }
|
|
|
914926 |
+
|
|
|
914926 |
for (;;) {
|
|
|
914926 |
char buffer[4096];
|
|
|
914926 |
int r = gzread (zlibfile, buffer, 4096);
|
|
|
914926 |
diff --git a/lib/encodings.c b/lib/encodings.c
|
|
|
914926 |
index d982827..ec8fb6b 100644
|
|
|
914926 |
--- a/lib/encodings.c
|
|
|
914926 |
+++ b/lib/encodings.c
|
|
|
914926 |
@@ -605,8 +605,10 @@ char *find_charset_locale (const char *charset)
|
|
|
914926 |
if (setlocale (LC_CTYPE, locale)) {
|
|
|
914926 |
free (encoding);
|
|
|
914926 |
goto out;
|
|
|
914926 |
- } else
|
|
|
914926 |
+ } else {
|
|
|
914926 |
+ free (locale);
|
|
|
914926 |
locale = NULL;
|
|
|
914926 |
+ }
|
|
|
914926 |
}
|
|
|
914926 |
free (encoding);
|
|
|
914926 |
}
|
|
|
914926 |
diff --git a/src/man.c b/src/man.c
|
|
|
914926 |
index cb0930b..12dca6e 100644
|
|
|
914926 |
--- a/src/man.c
|
|
|
914926 |
+++ b/src/man.c
|
|
|
914926 |
@@ -1404,6 +1404,7 @@ static pipeline *make_roff_command (const char *dir, const char *file,
|
|
|
914926 |
pipeline_command (p, cmd);
|
|
|
914926 |
}
|
|
|
914926 |
|
|
|
914926 |
+ free (fmt_prog);
|
|
|
914926 |
free (page_encoding);
|
|
|
914926 |
free (raw_pp_string);
|
|
|
914926 |
return p;
|
|
|
914926 |
diff --git a/src/mandb.c b/src/mandb.c
|
|
|
914926 |
index 550af8f..7ae0d02 100644
|
|
|
914926 |
--- a/src/mandb.c
|
|
|
914926 |
+++ b/src/mandb.c
|
|
|
914926 |
@@ -555,7 +555,7 @@ static int process_manpath (const char *manpath, int global_manpath,
|
|
|
914926 |
struct tried_catdirs_entry *tried;
|
|
|
914926 |
struct stat st;
|
|
|
914926 |
int run_mandb = 0;
|
|
|
914926 |
- struct dbpaths *dbpaths;
|
|
|
914926 |
+ struct dbpaths *dbpaths = NULL;
|
|
|
914926 |
int amount = 0;
|
|
|
914926 |
|
|
|
914926 |
if (global_manpath) { /* system db */
|
|
|
914926 |
@@ -571,8 +571,10 @@ static int process_manpath (const char *manpath, int global_manpath,
|
|
|
914926 |
tried->seen = 0;
|
|
|
914926 |
hashtable_install (tried_catdirs, catpath, strlen (catpath), tried);
|
|
|
914926 |
|
|
|
914926 |
- if (stat (manpath, &st) < 0 || !S_ISDIR (st.st_mode))
|
|
|
914926 |
- return 0;
|
|
|
914926 |
+ if (stat (manpath, &st) < 0 || !S_ISDIR (st.st_mode)) {
|
|
|
914926 |
+ amount = 0;
|
|
|
914926 |
+ goto out;
|
|
|
914926 |
+ }
|
|
|
914926 |
tried->seen = 1;
|
|
|
914926 |
|
|
|
914926 |
if (single_filename) {
|
|
|
914926 |
@@ -615,10 +617,13 @@ static int process_manpath (const char *manpath, int global_manpath,
|
|
|
914926 |
#endif /* SECURE_MAN_UID */
|
|
|
914926 |
|
|
|
914926 |
out:
|
|
|
914926 |
- cleanup_sigsafe (dbpaths);
|
|
|
914926 |
- pop_cleanup (cleanup_sigsafe, dbpaths);
|
|
|
914926 |
- cleanup (dbpaths);
|
|
|
914926 |
- pop_cleanup (cleanup, dbpaths);
|
|
|
914926 |
+ if (dbpaths) {
|
|
|
914926 |
+ cleanup_sigsafe (dbpaths);
|
|
|
914926 |
+ pop_cleanup (cleanup_sigsafe, dbpaths);
|
|
|
914926 |
+ cleanup (dbpaths);
|
|
|
914926 |
+ pop_cleanup (cleanup, dbpaths);
|
|
|
914926 |
+ }
|
|
|
914926 |
+
|
|
|
914926 |
free (database);
|
|
|
914926 |
database = NULL;
|
|
|
914926 |
|
|
|
914926 |
diff --git a/src/whatis.c b/src/whatis.c
|
|
|
914926 |
index 4cf14a5..f804c0e 100644
|
|
|
914926 |
--- a/src/whatis.c
|
|
|
914926 |
+++ b/src/whatis.c
|
|
|
914926 |
@@ -810,6 +810,8 @@ nextpage:
|
|
|
914926 |
free_mandata_elements (&info;;
|
|
|
914926 |
}
|
|
|
914926 |
|
|
|
914926 |
+ free (found_here);
|
|
|
914926 |
+
|
|
|
914926 |
for (i = 0; i < num_pages; ++i)
|
|
|
914926 |
free (lowpages[i]);
|
|
|
914926 |
free (lowpages);
|