summaryrefslogtreecommitdiffstats
path: root/apps/openssl.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2017-12-31 08:44:12 +0100
committerRichard Levitte <levitte@openssl.org>2018-01-06 19:27:57 +0100
commit391e987e9cd837446d3d0bf5505bbc7aa44b627e (patch)
treef1391884689e52e82d54f52de9346f3c1f2c8dfa /apps/openssl.c
parentCorrected 'cms' exit status when key or certificate cannot be opened (diff)
downloadopenssl-391e987e9cd837446d3d0bf5505bbc7aa44b627e.tar.xz
openssl-391e987e9cd837446d3d0bf5505bbc7aa44b627e.zip
apps: make sure prog_init only calculates once
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5002)
Diffstat (limited to 'apps/openssl.c')
-rw-r--r--apps/openssl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/apps/openssl.c b/apps/openssl.c
index 2cb49cbb35..dd7463edf3 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -787,12 +787,19 @@ static void list_disabled(void)
static LHASH_OF(FUNCTION) *prog_init(void)
{
- LHASH_OF(FUNCTION) *ret;
+ static LHASH_OF(FUNCTION) *ret = NULL;
+ static int prog_inited = 0;
FUNCTION *f;
size_t i;
+ if (prog_inited)
+ return ret;
+
+ prog_inited = 1;
+
/* Sort alphabetically within category. For nicer help displays. */
- for (i = 0, f = functions; f->name != NULL; ++f, ++i) ;
+ for (i = 0, f = functions; f->name != NULL; ++f, ++i)
+ ;
qsort(functions, i, sizeof(*functions), SortFnByName);
if ((ret = lh_FUNCTION_new(function_hash, function_cmp)) == NULL)