Re: [PATCH] newlib: libc: Fix memory leak in computematchjumps()

Mike Frysinger <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <ZWo9PoaKJ50skTkj@vapier>
On 02 Dec 2023 00:13, Kuan-Wei Chiu wrote:
> --- a/newlib/libc/posix/regcomp.c
> +++ b/newlib/libc/posix/regcomp.c
> @@ -2001,8 +2001,10 @@ struct re_guts *g;
>  	}
>  
>  	g->matchjump = (int*) malloc(g->mlen * sizeof(unsigned int));
> -	if (g->matchjump == NULL)	/* Not a fatal error */
> -		return;
> +	if (g->matchjump == NULL) { /* Not a fatal error */
> +        free(pmatches);
> +        return;
> +    }

the code uses tabs for indentation, but you used spaces for some reason
-mike
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmVqPT4ACgkQQWM7n+g3
9YGIGw/8CIfVZ8rmsvqjYdAbnpmZXYK8yERiPu0YHpYYy/0gZhVv2B3a/J1i/hh9
nD52nLUTzs+N2RFQMkRRPJx+5AM7rizq6T1NEJRkDVN4KcuwWZyh/jtm7k+Uq88q
QioRR53FeG6AweCO2nZpv7BGIT32a4sGRzk+qFoHCfhVoDKC39+rouUz6cAtuEo1
HFSDy+/ZSKSV87vD/UDok7apHpXQryqjY6bntM6TWbuFw7YqYcX2GnBBIRxLYeSs
NnIaY/YLGdoc8k7kRfpD/o2EX0TS2zPvv6QJRiS13qb9YwqmfKJ9mmLtGR0t7zHD
ODozJua5qYmD+8/ga0ftl3SffPT5cDl2pqYfY6QExeQsf604pqnJY079w6v78K1p
Qst8RG3nvYCPxWTy3HUAZsODcKQw4/iJYyHeRlwGmwPsBHO4Zj9e48pxj7a8lO6t
IZNxYPnjisXgPjxdfA2iF0XvtfdvwbHqM4gSziHyDhIHcImJL7IA1V6r6NPK4MGK
pzEZZHcAnIZcKkwUUNG4MnluUyWbozP3Uo0F2HlsL6w3I9zg4nK90XuavEYe91zN
b2cTOzN+gvp6fr4XfpDQNgpyZYSHuKrVX4aLvMmw0Ia2zkJtrKAuNlcEBnwo8PQo
hgOU+M3ybYVM/C4k6dsdKzaXv6gzvhxc/wV8m5K0MLFwqo/y4mk=
=WhFk
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.