apps/s_server.c:2847: error: NULL_DEREFERENCE
  pointer `sess` last assigned on line 2845 could be null and is dereferenced at line 2847, column 2.
Showing all 16 steps of the trace


apps/s_server.c:2840:1: start of procedure add_session()
2838.   static simple_ssl_session *first = NULL;
2839.   
2840. > static int add_session(SSL *ssl, SSL_SESSION *session)
2841.   	{
2842.   	simple_ssl_session *sess;

apps/s_server.c:2845:2: 
2843.   	unsigned char *p;
2844.   
2845. > 	sess = OPENSSL_malloc(sizeof(simple_ssl_session));
2846.   
2847.   	sess->idlen = session->session_id_length;

crypto/mem.c:294:1: start of procedure CRYPTO_malloc()
  292.   	}
  293.   
  294. > void *CRYPTO_malloc(int num, const char *file, int line)
  295.   	{
  296.   	void *ret = NULL;

crypto/mem.c:296:2: 
  294.   void *CRYPTO_malloc(int num, const char *file, int line)
  295.   	{
  296. > 	void *ret = NULL;
  297.   
  298.   	if (num <= 0) return NULL;

crypto/mem.c:298:6: Taking false branch
  296.   	void *ret = NULL;
  297.   
  298.   	if (num <= 0) return NULL;
              ^
  299.   
  300.   	allow_customize = 0;

crypto/mem.c:300:2: 
  298.   	if (num <= 0) return NULL;
  299.   
  300. > 	allow_customize = 0;
  301.   	if (malloc_debug_func != NULL)
  302.   		{

crypto/mem.c:301:6: Taking true branch
  299.   
  300.   	allow_customize = 0;
  301.   	if (malloc_debug_func != NULL)
              ^
  302.   		{
  303.   		allow_customize_debug = 0;

crypto/mem.c:303:3: 
  301.   	if (malloc_debug_func != NULL)
  302.   		{
  303. > 		allow_customize_debug = 0;
  304.   		malloc_debug_func(NULL, num, file, line, 0);
  305.   		}

crypto/mem.c:304:3: Skipping __function_pointer__(): unresolved function pointer
  302.   		{
  303.   		allow_customize_debug = 0;
  304.   		malloc_debug_func(NULL, num, file, line, 0);
           ^
  305.   		}
  306.   	ret = malloc_ex_func(num,file,line);

crypto/mem.c:306:2: Skipping __function_pointer__(): unresolved function pointer
  304.   		malloc_debug_func(NULL, num, file, line, 0);
  305.   		}
  306.   	ret = malloc_ex_func(num,file,line);
          ^
  307.   #ifdef LEVITTE_DEBUG_MEM
  308.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);

crypto/mem.c:310:6: Taking true branch
  308.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
  309.   #endif
  310.   	if (malloc_debug_func != NULL)
              ^
  311.   		malloc_debug_func(ret, num, file, line, 1);
  312.   

crypto/mem.c:311:3: Skipping __function_pointer__(): unresolved function pointer
  309.   #endif
  310.   	if (malloc_debug_func != NULL)
  311.   		malloc_debug_func(ret, num, file, line, 1);
           ^
  312.   
  313.   #ifndef OPENSSL_CPUID_OBJ

crypto/mem.c:317:12: Taking false branch
  315.            * sanitisation function can't be optimised out. NB: We only do
  316.            * this for >2Kb so the overhead doesn't bother us. */
  317.           if(ret && (num > 2048))
                    ^
  318.   	{	extern unsigned char cleanse_ctr;
  319.                   ((unsigned char *)ret)[0] = cleanse_ctr;

crypto/mem.c:323:2: 
  321.   #endif
  322.   
  323. > 	return ret;
  324.   	}
  325.   char *CRYPTO_strdup(const char *str, const char *file, int line)

crypto/mem.c:324:2: return from a call to CRYPTO_malloc
  322.   
  323.   	return ret;
  324.   	}
          ^
  325.   char *CRYPTO_strdup(const char *str, const char *file, int line)
  326.   	{

apps/s_server.c:2847:2: 
2845.   	sess = OPENSSL_malloc(sizeof(simple_ssl_session));
2846.   
2847. > 	sess->idlen = session->session_id_length;
2848.   	sess->derlen = i2d_SSL_SESSION(session, NULL);
2849.   

static int add_session(SSL *ssl, SSL_SESSION *session)
	{
	simple_ssl_session *sess;
	unsigned char *p;
	sess = OPENSSL_malloc(sizeof(simple_ssl_session));
	sess->idlen = session->session_id_length;
	sess->derlen = i2d_SSL_SESSION(session, NULL);
	sess->id = BUF_memdup(session->session_id, sess->idlen);
	sess->der = OPENSSL_malloc(sess->derlen);
	p = sess->der;
	i2d_SSL_SESSION(session, &p);
	sess->next = first;
	first = sess;
	BIO_printf(bio_err, "New session added to external cache\n");
	return 0;
	}
['static int add_session(SSL *ssl, SSL_SESSION *session)\n\t{\n\tsimple_ssl_session *sess;\n\tunsigned char *p;\n\tsess = OPENSSL_malloc(sizeof(simple_ssl_session));\n\tsess->idlen = session->session_id_length;\n\tsess->derlen = i2d_SSL_SESSION(session, NULL);\n\tsess->id = BUF_memdup(session->session_id, sess->idlen);\n\tsess->der = OPENSSL_malloc(sess->derlen);\n\tp = sess->der;\n\ti2d_SSL_SESSION(session, &p);\n\tsess->next = first;\n\tfirst = sess;\n\tBIO_printf(bio_err, "New session added to external cache\\n");\n\treturn 0;\n\t}', 'void *CRYPTO_malloc(int num, const char *file, int line)\n\t{\n\tvoid *ret = NULL;\n\tif (num <= 0) return NULL;\n\tallow_customize = 0;\n\tif (malloc_debug_func != NULL)\n\t\t{\n\t\tallow_customize_debug = 0;\n\t\tmalloc_debug_func(NULL, num, file, line, 0);\n\t\t}\n\tret = malloc_ex_func(num,file,line);\n#ifdef LEVITTE_DEBUG_MEM\n\tfprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\\n", ret, num);\n#endif\n\tif (malloc_debug_func != NULL)\n\t\tmalloc_debug_func(ret, num, file, line, 1);\n#ifndef OPENSSL_CPUID_OBJ\n        if(ret && (num > 2048))\n\t{\textern unsigned char cleanse_ctr;\n                ((unsigned char *)ret)[0] = cleanse_ctr;\n\t}\n#endif\n\treturn ret;\n\t}']