diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2015-07-18 21:21:29 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2015-07-18 21:21:29 +0000 |
commit | 7048147ab293cde448d908021582a61fd548f44f (patch) | |
tree | c22769642b6450dee7edcec9cf140fbdc950ef9b /lib | |
parent | 5474b88703c6704a063d304c2a57bb7ce9ee36df (diff) |
Coverity ID 78910 - Yet another stupid API designed to not show failures. do the
lease worst alternative and do nothing rather than dereference NULL, but having
a function with fundamentally broken API to simply make a list of strings, sort them,
and call a function with each string as an argument is really quite silly....
and of course it was exposed API that the ecosystem uses that we can't delete.. yet.
ok miod@ doug@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/objects/o_names.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/libcrypto/objects/o_names.c b/lib/libcrypto/objects/o_names.c index e77e4a10939..81240db204a 100644 --- a/lib/libcrypto/objects/o_names.c +++ b/lib/libcrypto/objects/o_names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: o_names.c,v 1.20 2015/02/10 11:22:21 jsing Exp $ */ +/* $OpenBSD: o_names.c,v 1.21 2015/07/18 21:21:28 beck Exp $ */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -299,14 +299,16 @@ OBJ_NAME_do_all_sorted(int type, void (*fn)(const OBJ_NAME *, void *arg), d.names = reallocarray(NULL, lh_OBJ_NAME_num_items(names_lh), sizeof *d.names); d.n = 0; - OBJ_NAME_do_all(type, do_all_sorted_fn, &d); + if (d.names != NULL) { + OBJ_NAME_do_all(type, do_all_sorted_fn, &d); - qsort((void *)d.names, d.n, sizeof *d.names, do_all_sorted_cmp); + qsort((void *)d.names, d.n, sizeof *d.names, do_all_sorted_cmp); - for (n = 0; n < d.n; ++n) - fn(d.names[n], arg); + for (n = 0; n < d.n; ++n) + fn(d.names[n], arg); - free((void *)d.names); + free(d.names); + } } static int free_type; |