* io/ftw.c (open_dir_stream): Return right away if REALLOC fails.
authorUlrich Drepper <drepper@redhat.com>
Wed, 10 May 2006 06:39:15 +0000 (06:39 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 10 May 2006 06:39:15 +0000 (06:39 +0000)
[Coverity CID 229, 230]

* argp/argp-help.c (hol_entry_help): Handle STATE==NULL in ARG and
DGETTEXT calls.
(hol_help): Likewise.  [Coverity CID 226, 227]

* string/argz-replace.c (__argz_replace): Unconditionally call
free on SRC.  [Coverity CID 225]

* nis/nis_creategroup.c (nis_creategroup): No need to duplicate
the return value of __nis_default_owner and __nis_default_group,
it has been especially allocated.  [Coverity CID 224]

ChangeLog
argp/argp-help.c
io/ftw.c
nis/nis_creategroup.c
string/argz-replace.c

index a04f97b48317a819a4660ec1bf64a67950bb1e00..feb50d1f2e6e62e38f5cde4cf6b8ec67a80d065f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2006-05-09  Ulrich Drepper  <drepper@redhat.com>
 
+       * io/ftw.c (open_dir_stream): Return right away if REALLOC fails.
+       [Coverity CID 229, 230]
+
+       * argp/argp-help.c (hol_entry_help): Handle STATE==NULL in ARG and
+       DGETTEXT calls.
+       (hol_help): Likewise.  [Coverity CID 226, 227]
+
+       * string/argz-replace.c (__argz_replace): Unconditionally call
+       free on SRC.  [Coverity CID 225]
+
+       * nis/nis_creategroup.c (nis_creategroup): No need to duplicate
+       the return value of __nis_default_owner and __nis_default_group,
+       it has been especially allocated.  [Coverity CID 224]
+
        * nis/nis_defaults.c (searchXYX): New functions.  Used by both
        searchgroup and searchowner.  Significantly simplified.
        (__nis_default_owner): Remove duplication.  Do not locally copy the
index 7ba621b7356b43d931954ffed420e3287eac4f3e..13c0820710d6173d835b290d1650ecfdbda9979a 100644 (file)
@@ -1105,7 +1105,9 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
            __argp_fmtstream_putc (stream, '-');
            __argp_fmtstream_putc (stream, *so);
            if (!have_long_opt || uparams.dup_args)
-             arg (real, " %s", "[%s]", state->root_argp->argp_domain, stream);
+             arg (real, " %s", "[%s]",
+                  state == NULL ? NULL : state->root_argp->argp_domain,
+                  stream);
            else if (real->arg)
              hhstate->suppressed_dup_arg = 1;
          }
@@ -1125,7 +1127,8 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
               have been done on the original; but documentation options
               should be pretty rare anyway...  */
            __argp_fmtstream_puts (stream,
-                                  dgettext (state->root_argp->argp_domain,
+                                  dgettext (state == NULL ? NULL
+                                            : state->root_argp->argp_domain,
                                             opt->name));
          }
     }
@@ -1138,7 +1141,8 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
          {
            comma (uparams.long_opt_col, &pest);
            __argp_fmtstream_printf (stream, "--%s", opt->name);
-           arg (real, "=%s", "[=%s]", state->root_argp->argp_domain, stream);
+           arg (real, "=%s", "[=%s]",
+                state == NULL ? NULL : state->root_argp->argp_domain, stream);
          }
     }
 
@@ -1157,7 +1161,8 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
     }
   else
     {
-      const char *tstr = real->doc ? dgettext (state->root_argp->argp_domain,
+      const char *tstr = real->doc ? dgettext (state == NULL ? NULL
+                                              : state->root_argp->argp_domain,
                                               real->doc) : 0;
       const char *fstr = filter_doc (tstr, real->key, entry->argp, state);
       if (fstr && *fstr)
@@ -1205,7 +1210,8 @@ hol_help (struct hol *hol, const struct argp_state *state,
 
   if (hhstate.suppressed_dup_arg && uparams.dup_args_note)
     {
-      const char *tstr = dgettext (state->root_argp->argp_domain, "\
+      const char *tstr = dgettext (state == NULL ? NULL
+                                  : state->root_argp->argp_domain, "\
 Mandatory or optional arguments to long options are also mandatory or \
 optional for any corresponding short options.");
       const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_DUP_ARGS_NOTE,
index 5c339a06247b58d08b7885fe4ceed0f6c42e4200..413871744eac8667ab1fe5bcb3a3c6bac3c98434 100644 (file)
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -301,8 +301,7 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp)
                      int save_err = errno;
                      free (buf);
                      __set_errno (save_err);
-                     result = -1;
-                     break;
+                     return -1;
                    }
                  buf = newp;
                }
index a7808abf4bdf28867f28d8b52bbb4b68f29dc598..0e9e13d5e567b45481598eb92eb24b7925c8689e 100644 (file)
@@ -52,8 +52,8 @@ nis_creategroup (const_nis_name group, unsigned int flags)
 
       obj->zo_oid.ctime = obj->zo_oid.mtime = time (NULL);
       obj->zo_name = strdup (leafbuf);
-      obj->zo_owner = strdup (__nis_default_owner (NULL));
-      obj->zo_group = strdup (__nis_default_group (NULL));
+      obj->zo_owner = __nis_default_owner (NULL);
+      obj->zo_group = __nis_default_group (NULL);
       obj->zo_domain = strdup (domainbuf);
       if (obj->zo_name == NULL || obj->zo_owner == NULL
          || obj->zo_group == NULL || obj->zo_domain == NULL)
index 3c4062488ea4bd7b4ffff83401fdd4aff6b506db..1b0eb15fd747654074ffb73838d5a451398e29b8 100644 (file)
@@ -1,5 +1,5 @@
 /* String replacement in an argz vector
-   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <miles@gnu.ai.mit.edu>
 
@@ -121,8 +121,7 @@ __argz_replace (char **argz, size_t *argz_len, const char *str, const char *with
          if (! delayed_copy)
            /* We never found any instances of str.  */
            {
-             if (src)
-               free (src);
+             free (src);
              *argz = dst;
              *argz_len = dst_len;
            }