RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   11-Jun-2007 11:36:41
  Branch: HEAD                             Handle: 2007061110364100

  Modified files:
    rpm/popt                popt.c

  Log:
    plug the other memory leaks too.

  Summary:
    Revision    Changes     Path
    1.97        +15 -12     rpm/popt/popt.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/popt/popt.c
  ============================================================================
  $ cvs diff -u -r1.96 -r1.97 popt.c
  --- rpm/popt/popt.c   11 Jun 2007 06:14:11 -0000      1.96
  +++ rpm/popt/popt.c   11 Jun 2007 09:36:41 -0000      1.97
  @@ -377,9 +377,10 @@
        /[EMAIL PROTECTED] internalState @*/
   {
       poptItem item = con->doExec;
  -    const char ** argv;
  +    const char ** argv = NULL;
       int argc = 0;
       int rc;
  +    int ec = POPT_ERROR_ERRNO;
   
       if (item == NULL) /*XXX can't happen*/
        return POPT_ERROR_NOARG;
  @@ -399,8 +400,8 @@
       } else
        argv[argc] = findProgramPath(item->argv[0]);
       if (argv[argc++] == NULL) {
  -     free(argv);
  -     return POPT_ERROR_NOARG;
  +     ec = POPT_ERROR_NOARG;
  +     goto exit;
       }
   
       if (item->argc > 1) {
  @@ -423,9 +424,9 @@
   
   #if defined(hpux) || defined(__hpux)
       rc = setresgid(getgid(), getgid(),-1);
  -    if (rc) return POPT_ERROR_ERRNO;
  +    if (rc) goto exit;
       rc = setresuid(getuid(), getuid(),-1);
  -    if (rc) return POPT_ERROR_ERRNO;
  +    if (rc) goto exit;
   #else
   /*
    * XXX " ... on BSD systems setuid() should be preferred over setreuid()"
  @@ -434,22 +435,22 @@
    */
   #if defined(HAVE_SETUID)
       rc = setgid(getgid());
  -    if (rc) return POPT_ERROR_ERRNO;
  +    if (rc) goto exit;
       rc = setuid(getuid());
  -    if (rc) return POPT_ERROR_ERRNO;
  +    if (rc) goto exit;
   #elif defined (HAVE_SETREUID)
       rc = setregid(getgid(), getgid());
  -    if (rc) return POPT_ERROR_ERRNO;
  +    if (rc) goto exit;
       rc = setreuid(getuid(), getuid());
  -    if (rc) return POPT_ERROR_ERRNO;
  +    if (rc) goto exit;
   #else
       ; /* Can't drop privileges */
   #endif
   #endif
   
       if (argv[0] == NULL) {
  -     free(argv);
  -     return POPT_ERROR_NOARG;
  +     ec = POPT_ERROR_NOARG;
  +     goto exit;
       }
   
   #ifdef       MYDEBUG
  @@ -464,7 +465,9 @@
   
       rc = execvp(argv[0], (char *const *)argv);
   
  -    return POPT_ERROR_ERRNO;
  +exit:
  +    if (argv) free(argv);
  +    return ec;
   }
   /[EMAIL PROTECTED] =boundswrite @*/
   
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to