[lxc-devel] [PATCH 1/1] cppcheck: fix unchecked realloc in lxc_info.c

Stéphane Graber stgraber at ubuntu.com
Tue Apr 15 20:56:39 UTC 2014


On Tue, Apr 15, 2014 at 03:53:35PM -0500, Serge Hallyn wrote:
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/lxc_info.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c
> index 24d6f9b..e1e39c0 100644
> --- a/src/lxc/lxc_info.c
> +++ b/src/lxc/lxc_info.c
> @@ -50,9 +50,13 @@ static int filter_count = 0;
>  
>  static int my_parser(struct lxc_arguments* args, int c, char* arg)
>  {
> +	char **newk;
>  	switch (c) {
>  	case 'c':
> -		key = realloc(key, keys+1 * sizeof(key[0]));
> +		newk = realloc(key, keys+1 * sizeof(key[0]));
> +		if (!newk)
> +			return -1;
> +		key = newk;
>  		key[keys] = arg;
>  		keys++;
>  		break;
> -- 
> 1.9.1
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140415/30537f2a/attachment.sig>


More information about the lxc-devel mailing list