From: jsing Date: Fri, 23 Dec 2022 02:26:16 +0000 (+0000) Subject: Make UI_destroy_method() NULL safe. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d533e99e2b9abc3c34fe81fdb8830e71b1c62c50;p=openbsd Make UI_destroy_method() NULL safe. ok tb@ --- diff --git a/lib/libcrypto/ui/ui_lib.c b/lib/libcrypto/ui/ui_lib.c index 69428f9a2ab..e36c270a874 100644 --- a/lib/libcrypto/ui/ui_lib.c +++ b/lib/libcrypto/ui/ui_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_lib.c,v 1.47 2022/12/23 02:22:58 jsing Exp $ */ +/* $OpenBSD: ui_lib.c,v 1.48 2022/12/23 02:26:16 jsing Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ @@ -575,11 +575,13 @@ UI_create_method(const char *name) LCRYPTO_ALIAS(UI_create_method) void -UI_destroy_method(UI_METHOD *ui_method) +UI_destroy_method(UI_METHOD *method) { - free(ui_method->name); - ui_method->name = NULL; - free(ui_method); + if (method == NULL) + return; + + free(method->name); + free(method); } LCRYPTO_ALIAS(UI_destroy_method)