apps/dhparam.c:429: error: NULL_DEREFERENCE
  pointer `dh` last assigned on line 169 could be null and is dereferenced by call to `DH_free()` at line 429, column 5.
Showing all 25 steps of the trace


apps/dhparam.c:166:1: start of procedure dhparam_main()
164.   };
165.   
166. > int dhparam_main(int argc, char **argv)
167.   {
168.       BIO *in = NULL, *out = NULL;

apps/dhparam.c:168:5: 
166.   int dhparam_main(int argc, char **argv)
167.   {
168. >     BIO *in = NULL, *out = NULL;
169.       DH *dh = NULL;
170.       char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;

apps/dhparam.c:169:5: 
167.   {
168.       BIO *in = NULL, *out = NULL;
169. >     DH *dh = NULL;
170.       char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
171.       int dsaparam = 0, i, text = 0, C = 0, ret = 1, num = 0, g = 0;

apps/dhparam.c:170:5: 
168.       BIO *in = NULL, *out = NULL;
169.       DH *dh = NULL;
170. >     char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
171.       int dsaparam = 0, i, text = 0, C = 0, ret = 1, num = 0, g = 0;
172.       int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0;

apps/dhparam.c:171:5: 
169.       DH *dh = NULL;
170.       char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
171. >     int dsaparam = 0, i, text = 0, C = 0, ret = 1, num = 0, g = 0;
172.       int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0;
173.       OPTION_CHOICE o;

apps/dhparam.c:172:5: 
170.       char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
171.       int dsaparam = 0, i, text = 0, C = 0, ret = 1, num = 0, g = 0;
172. >     int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0;
173.       OPTION_CHOICE o;
174.   

apps/dhparam.c:175:5: Skipping opt_init(): empty list of specs
173.       OPTION_CHOICE o;
174.   
175.       prog = opt_init(argc, argv, dhparam_options);
           ^
176.       while ((o = opt_next()) != OPT_EOF) {
177.           switch (o) {

apps/dhparam.c:176:12: Loop condition is true. Entering loop body
174.   
175.       prog = opt_init(argc, argv, dhparam_options);
176.       while ((o = opt_next()) != OPT_EOF) {
                  ^
177.           switch (o) {
178.           case OPT_EOF:

apps/dhparam.c:177:9: 
175.       prog = opt_init(argc, argv, dhparam_options);
176.       while ((o = opt_next()) != OPT_EOF) {
177. >         switch (o) {
178.           case OPT_EOF:
179.           case OPT_ERR:

apps/dhparam.c:178:9: Switch condition is false. Skipping switch case
176.       while ((o = opt_next()) != OPT_EOF) {
177.           switch (o) {
178.           case OPT_EOF:
               ^
179.           case OPT_ERR:
180.    opthelp:

apps/dhparam.c:179:9: Switch condition is false. Skipping switch case
177.           switch (o) {
178.           case OPT_EOF:
179.           case OPT_ERR:
               ^
180.    opthelp:
181.               BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);

apps/dhparam.c:183:9: Switch condition is true. Entering switch case
181.               BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
182.               goto end;
183.           case OPT_HELP:
               ^
184.               opt_help(dhparam_options);
185.               ret = 0;

apps/dhparam.c:184:13: Skipping opt_help(): empty list of specs
182.               goto end;
183.           case OPT_HELP:
184.               opt_help(dhparam_options);
                   ^
185.               ret = 0;
186.               goto end;

apps/dhparam.c:185:13: 
183.           case OPT_HELP:
184.               opt_help(dhparam_options);
185. >             ret = 0;
186.               goto end;
187.           case OPT_INFORM:

apps/dhparam.c:426:2: 
424.       }
425.       ret = 0;
426. >  end:
427.       BIO_free(in);
428.       BIO_free_all(out);

apps/dhparam.c:427:5: 
425.       ret = 0;
426.    end:
427. >     BIO_free(in);
428.       BIO_free_all(out);
429.       DH_free(dh);

crypto/bio/bio_lib.c:106:1: start of procedure BIO_free()
  104.   }
  105.   
  106. > int BIO_free(BIO *a)
  107.   {
  108.       int i;

crypto/bio/bio_lib.c:110:9: Taking true branch
  108.       int i;
  109.   
  110.       if (a == NULL)
                 ^
  111.           return (0);
  112.   

crypto/bio/bio_lib.c:111:9: 
  109.   
  110.       if (a == NULL)
  111. >         return (0);
  112.   
  113.       i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_BIO);

crypto/bio/bio_lib.c:135:1: return from a call to BIO_free
  133.       OPENSSL_free(a);
  134.       return (1);
  135. > }
  136.   
  137.   void BIO_vfree(BIO *a)

apps/dhparam.c:428:5: 
426.    end:
427.       BIO_free(in);
428. >     BIO_free_all(out);
429.       DH_free(dh);
430.       return (ret);

crypto/bio/bio_lib.c:499:1: start of procedure BIO_free_all()
  497.   }
  498.   
  499. > void BIO_free_all(BIO *bio)
  500.   {
  501.       BIO *b;

crypto/bio/bio_lib.c:504:12: Loop condition is false. Leaving loop
  502.       int ref;
  503.   
  504.       while (bio != NULL) {
                    ^
  505.           b = bio;
  506.           ref = b->references;

crypto/bio/bio_lib.c:513:1: return from a call to BIO_free_all
  511.               break;
  512.       }
  513. > }
  514.   
  515.   BIO *BIO_dup_chain(BIO *in)

apps/dhparam.c:429:5: 
427.       BIO_free(in);
428.       BIO_free_all(out);
429. >     DH_free(dh);
430.       return (ret);
431.   }
