In case lh_OBJ_NAME_insert returns NULL due to a failed malloc, onp
authormbuhl <mbuhl@openbsd.org>
Tue, 8 Nov 2022 23:19:09 +0000 (23:19 +0000)
committermbuhl <mbuhl@openbsd.org>
Tue, 8 Nov 2022 23:19:09 +0000 (23:19 +0000)
is leaked in OBJ_NAME_add.
ok tb
Found by CodeChecker.

lib/libcrypto/objects/o_names.c

index a9e5f85..2cdd2f3 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: o_names.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */
+/* $OpenBSD: o_names.c,v 1.23 2022/11/08 23:19:09 mbuhl Exp $ */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -197,6 +197,7 @@ OBJ_NAME_add(const char *name, int type, const char *data)
                free(ret);
        } else {
                if (lh_OBJ_NAME_error(names_lh)) {
+                       free(onp);
                        /* ERROR */
                        return (0);
                }