On Tue, Nov 08, 2022 at 01:33:47PM +0100, Moritz Buhl wrote:
> In case lh_OBJ_NAME_insert returns NULL due to a failed malloc, onp
> is leaked in OBJ_NAME_add.
> 
> Found by CodeChecker.
> 
> OK?
> mbuhl
> 
> Index: lib/libcrypto/objects/o_names.c
> ===================================================================
> RCS file: /cvs/src/lib/libcrypto/objects/o_names.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 o_names.c
> --- lib/libcrypto/objects/o_names.c   29 Jan 2017 17:49:23 -0000      1.22
> +++ lib/libcrypto/objects/o_names.c   8 Nov 2022 12:24:47 -0000
> @@ -196,6 +196,7 @@ OBJ_NAME_add(const char *name, int type,
>               }
>               free(ret);
>       } else {
> +             free(onp);
>               if (lh_OBJ_NAME_error(names_lh)) {

Actually, it needs freeing only here. If lh_OBJ_NAME_error() returns 0,
there was no error and a hash-entry containing NULL was replaced.

>                       /* ERROR */
>                       return (0);

Reply via email to