diff libtomcrypt/demos/constants.c @ 1733:d529a52b2f7c coverity coverity

merge coverity from main
author Matt Johnston <matt@ucc.asn.au>
date Fri, 26 Jun 2020 21:07:34 +0800
parents e9dba7abd939
children
line wrap: on
line diff
--- a/libtomcrypt/demos/constants.c	Thu Mar 21 23:28:59 2019 +0800
+++ b/libtomcrypt/demos/constants.c	Fri Jun 26 21:07:34 2020 +0800
@@ -65,9 +65,10 @@
          /* get and print the length of the names (and values) list */
          if (crypt_list_all_constants(NULL, &names_list_len) != 0) exit(EXIT_FAILURE);
          /* get and print the names (and values) list */
-         names_list = malloc(names_list_len);
+         if ((names_list = malloc(names_list_len)) == NULL) exit(EXIT_FAILURE);
          if (crypt_list_all_constants(names_list, &names_list_len) != 0) exit(EXIT_FAILURE);
          printf("%s\n", names_list);
+         free(names_list);
       }
    } else if (argc == 3) {
       if (strcmp(argv[1], "-s") == 0) {