apps/s_server.c:3008: error: NULL_DEREFERENCE
  pointer `rsa_tmp` last assigned on line 3006 could be null and is dereferenced by call to `RSA_free()` at line 3008, column 13.
Showing all 26 steps of the trace


apps/s_server.c:2993:1: start of procedure tmp_rsa_cb()
2991.   
2992.   #ifndef OPENSSL_NO_RSA
2993. > static RSA *tmp_rsa_cb(SSL *s, int is_export, int keylength)
2994.   {
2995.       BIGNUM *bn = NULL;

apps/s_server.c:2995:5: 
2993.   static RSA *tmp_rsa_cb(SSL *s, int is_export, int keylength)
2994.   {
2995. >     BIGNUM *bn = NULL;
2996.       static RSA *rsa_tmp = NULL;
2997.   

apps/s_server.c:2996:5: 
2994.   {
2995.       BIGNUM *bn = NULL;
2996. >     static RSA *rsa_tmp = NULL;
2997.   
2998.       if (!rsa_tmp && ((bn = BN_new()) == NULL))

apps/s_server.c:2998:10: Taking true branch
2996.       static RSA *rsa_tmp = NULL;
2997.   
2998.       if (!rsa_tmp && ((bn = BN_new()) == NULL))
                 ^
2999.           BIO_printf(bio_err, "Allocation error in generating RSA key\n");
3000.       if (!rsa_tmp && bn) {

apps/s_server.c:2998:22: Taking false branch
2996.       static RSA *rsa_tmp = NULL;
2997.   
2998.       if (!rsa_tmp && ((bn = BN_new()) == NULL))
                             ^
2999.           BIO_printf(bio_err, "Allocation error in generating RSA key\n");
3000.       if (!rsa_tmp && bn) {

apps/s_server.c:3000:10: Taking true branch
2998.       if (!rsa_tmp && ((bn = BN_new()) == NULL))
2999.           BIO_printf(bio_err, "Allocation error in generating RSA key\n");
3000.       if (!rsa_tmp && bn) {
                 ^
3001.           if (!s_quiet) {
3002.               BIO_printf(bio_err, "Generating temp (%d bit) RSA key...",

apps/s_server.c:3000:21: Taking true branch
2998.       if (!rsa_tmp && ((bn = BN_new()) == NULL))
2999.           BIO_printf(bio_err, "Allocation error in generating RSA key\n");
3000.       if (!rsa_tmp && bn) {
                            ^
3001.           if (!s_quiet) {
3002.               BIO_printf(bio_err, "Generating temp (%d bit) RSA key...",

apps/s_server.c:3001:14: Taking false branch
2999.           BIO_printf(bio_err, "Allocation error in generating RSA key\n");
3000.       if (!rsa_tmp && bn) {
3001.           if (!s_quiet) {
                     ^
3002.               BIO_printf(bio_err, "Generating temp (%d bit) RSA key...",
3003.                          keylength);

apps/s_server.c:3006:14: 
3004.               (void)BIO_flush(bio_err);
3005.           }
3006. >         if (!BN_set_word(bn, RSA_F4) || ((rsa_tmp = RSA_new()) == NULL) ||
3007.               !RSA_generate_key_ex(rsa_tmp, keylength, bn, NULL)) {
3008.               RSA_free(rsa_tmp);

crypto/bn/bn_lib.c:531:1: start of procedure BN_set_word()
  529.   }
  530.   
  531. > int BN_set_word(BIGNUM *a, BN_ULONG w)
  532.   {
  533.       bn_check_top(a);

crypto/bn/bn_lib.c:534:9: Condition is true
  532.   {
  533.       bn_check_top(a);
  534.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                 ^
  535.           return (0);
  536.       a->neg = 0;

crypto/bn/bn_lib.c:534:9: Taking false branch
  532.   {
  533.       bn_check_top(a);
  534.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                 ^
  535.           return (0);
  536.       a->neg = 0;

crypto/bn/bn_lib.c:536:5: 
  534.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
  535.           return (0);
  536. >     a->neg = 0;
  537.       a->d[0] = w;
  538.       a->top = (w ? 1 : 0);

crypto/bn/bn_lib.c:537:5: 
  535.           return (0);
  536.       a->neg = 0;
  537. >     a->d[0] = w;
  538.       a->top = (w ? 1 : 0);
  539.       bn_check_top(a);

crypto/bn/bn_lib.c:538:15: Condition is true
  536.       a->neg = 0;
  537.       a->d[0] = w;
  538.       a->top = (w ? 1 : 0);
                       ^
  539.       bn_check_top(a);
  540.       return (1);

crypto/bn/bn_lib.c:538:5: 
  536.       a->neg = 0;
  537.       a->d[0] = w;
  538. >     a->top = (w ? 1 : 0);
  539.       bn_check_top(a);
  540.       return (1);

crypto/bn/bn_lib.c:540:5: 
  538.       a->top = (w ? 1 : 0);
  539.       bn_check_top(a);
  540. >     return (1);
  541.   }
  542.   

crypto/bn/bn_lib.c:541:1: return from a call to BN_set_word
  539.       bn_check_top(a);
  540.       return (1);
  541. > }
  542.   
  543.   BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)

apps/s_server.c:3006:14: Taking false branch
3004.               (void)BIO_flush(bio_err);
3005.           }
3006.           if (!BN_set_word(bn, RSA_F4) || ((rsa_tmp = RSA_new()) == NULL) ||
                     ^
3007.               !RSA_generate_key_ex(rsa_tmp, keylength, bn, NULL)) {
3008.               RSA_free(rsa_tmp);

apps/s_server.c:3006:42: 
3004.               (void)BIO_flush(bio_err);
3005.           }
3006. >         if (!BN_set_word(bn, RSA_F4) || ((rsa_tmp = RSA_new()) == NULL) ||
3007.               !RSA_generate_key_ex(rsa_tmp, keylength, bn, NULL)) {
3008.               RSA_free(rsa_tmp);

crypto/rsa/rsa_lib.c:72:1: start of procedure RSA_new()
  70.   static const RSA_METHOD *default_RSA_meth = NULL;
  71.   
  72. > RSA *RSA_new(void)
  73.   {
  74.       RSA *r = RSA_new_method(NULL);

crypto/rsa/rsa_lib.c:74:5: Skipping RSA_new_method(): empty list of specs
  72.   RSA *RSA_new(void)
  73.   {
  74.       RSA *r = RSA_new_method(NULL);
            ^
  75.   
  76.       return r;

crypto/rsa/rsa_lib.c:76:5: 
  74.       RSA *r = RSA_new_method(NULL);
  75.   
  76. >     return r;
  77.   }
  78.   

crypto/rsa/rsa_lib.c:77:1: return from a call to RSA_new
  75.   
  76.       return r;
  77. > }
  78.   
  79.   void RSA_set_default_method(const RSA_METHOD *meth)

apps/s_server.c:3006:42: Taking true branch
3004.               (void)BIO_flush(bio_err);
3005.           }
3006.           if (!BN_set_word(bn, RSA_F4) || ((rsa_tmp = RSA_new()) == NULL) ||
                                                 ^
3007.               !RSA_generate_key_ex(rsa_tmp, keylength, bn, NULL)) {
3008.               RSA_free(rsa_tmp);

apps/s_server.c:3008:13: 
3006.           if (!BN_set_word(bn, RSA_F4) || ((rsa_tmp = RSA_new()) == NULL) ||
3007.               !RSA_generate_key_ex(rsa_tmp, keylength, bn, NULL)) {
3008. >             RSA_free(rsa_tmp);
3009.               rsa_tmp = NULL;
3010.           }
