On Fri, Oct 24, 2014 at 05:39:32AM +0000, Marcelo Araujo wrote:
> Author: araujo (ports committer)
> Date: Fri Oct 24 05:39:32 2014
> New Revision: 273576
> URL: https://svnweb.freebsd.org/changeset/base/273576
> 
> Log:
>   Fix a leaked Storage Variable.
>   
>  int
>  uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class)
>  {
> -     const char *spec;
> +     const char *cp, *spec;
>       bus_addr_t addr = ~0U;
>       int error;
>  
> @@ -214,12 +214,12 @@ uart_getenv(int devtype, struct uart_dev
>        * port (resp).
>        */
>       if (devtype == UART_DEV_CONSOLE)
> -             spec = kern_getenv("hw.uart.console");
> +             cp = kern_getenv("hw.uart.console");
>       else if (devtype == UART_DEV_DBGPORT)
> -             spec = kern_getenv("hw.uart.dbgport");
> +             cp = kern_getenv("hw.uart.dbgport");
>       else
> -             spec = NULL;
> -     if (spec == NULL)
> +             cp = NULL;
> +     if (cp == NULL)
>               return (ENXIO);
[..]
>               default:
> +                     freeenv(__DECONST(char *, cp));
>                       return (EINVAL);
>               }
>               if (*spec == '\0')
>                       break;
> -             if (*spec != ',')
> +             if (*spec != ',') {
> +                     freeenv(__DECONST(char *, cp));
>                       return (EINVAL);
> +             }
>               spec++;
>       }
> +     freeenv(__DECONST(char *, cp));
>  

Why not 'char *cp;'? That would avoid __DECONST entirely and would not
require spec to change type.

There are some cosmetics around that may be worth fixing (e.g. if,
else-if instead of switch, while (1) instead of for (;;)).

-- 
Mateusz Guzik <mjguzik gmail.com>
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to