apps/ts.c:1077: error: NULL_DEREFERENCE
  pointer `cert_ctx` last assigned on line 1074 could be null and is dereferenced at line 1077, column 2.
Showing all 20 steps of the trace


apps/ts.c:1067:1: start of procedure create_cert_store()
1065.   	}
1066.   
1067. > static X509_STORE *create_cert_store(char *ca_path, char *ca_file)
1068.   	{
1069.   	X509_STORE *cert_ctx = NULL;

apps/ts.c:1069:2: 
1067.   static X509_STORE *create_cert_store(char *ca_path, char *ca_file)
1068.   	{
1069. > 	X509_STORE *cert_ctx = NULL;
1070.   	X509_LOOKUP *lookup = NULL;
1071.   	int i;

apps/ts.c:1070:2: 
1068.   	{
1069.   	X509_STORE *cert_ctx = NULL;
1070. > 	X509_LOOKUP *lookup = NULL;
1071.   	int i;
1072.   

apps/ts.c:1074:2: 
1072.   
1073.   	/* Creating the X509_STORE object. */
1074. > 	cert_ctx = X509_STORE_new();
1075.   
1076.   	/* Setting the callback for certificate chain verification. */

crypto/x509/x509_lu.c:178:1: start of procedure X509_STORE_new()
  176.   	}
  177.   
  178. > X509_STORE *X509_STORE_new(void)
  179.   	{
  180.   	X509_STORE *ret;

crypto/x509/x509_lu.c:182:6: 
  180.   	X509_STORE *ret;
  181.   
  182. > 	if ((ret=(X509_STORE *)OPENSSL_malloc(sizeof(X509_STORE))) == NULL)
  183.   		return NULL;
  184.   	ret->objs = sk_X509_OBJECT_new(x509_object_cmp);

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

crypto/mem.c:293:2: 
    291.   void *CRYPTO_malloc(int num, const char *file, int line)
    292.   	{
    293. > 	void *ret = NULL;
    294.   	extern unsigned char cleanse_ctr;
    295.   

crypto/mem.c:296:6: Taking false branch
    294.   	extern unsigned char cleanse_ctr;
    295.   
    296.   	if (num <= 0) return NULL;
                ^
    297.   
    298.   	allow_customize = 0;

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

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

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

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

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

crypto/mem.c:317:2: 
    315.                   ((unsigned char *)ret)[0] = cleanse_ctr;
    316.   
    317. > 	return ret;
    318.   	}
    319.   

crypto/mem.c:318:2: return from a call to CRYPTO_malloc
    316.   
    317.   	return ret;
    318.   	}
            ^
    319.   
    320.   void *CRYPTO_realloc(void *str, int num, const char *file, int line)

crypto/x509/x509_lu.c:182:6: Taking true branch
  180.   	X509_STORE *ret;
  181.   
  182.   	if ((ret=(X509_STORE *)OPENSSL_malloc(sizeof(X509_STORE))) == NULL)
              ^
  183.   		return NULL;
  184.   	ret->objs = sk_X509_OBJECT_new(x509_object_cmp);

crypto/x509/x509_lu.c:183:3: 
  181.   
  182.   	if ((ret=(X509_STORE *)OPENSSL_malloc(sizeof(X509_STORE))) == NULL)
  183. > 		return NULL;
  184.   	ret->objs = sk_X509_OBJECT_new(x509_object_cmp);
  185.   	ret->cache=1;

crypto/x509/x509_lu.c:204:2: return from a call to X509_STORE_new
  202.   	ret->references=1;
  203.   	return ret;
  204.   	}
          ^
  205.   
  206.   static void cleanup(X509_OBJECT *a)

apps/ts.c:1077:2: 
1075.   
1076.   	/* Setting the callback for certificate chain verification. */
1077. > 	X509_STORE_set_verify_cb_func(cert_ctx, verify_cb);
1078.   
1079.   	/* Adding a trusted certificate directory source. */

static X509_STORE *create_cert_store(char *ca_path, char *ca_file)
	{
	X509_STORE *cert_ctx = NULL;
	X509_LOOKUP *lookup = NULL;
	int i;
	cert_ctx = X509_STORE_new();
	X509_STORE_set_verify_cb_func(cert_ctx, verify_cb);
	if (ca_path)
		{
		lookup = X509_STORE_add_lookup(cert_ctx,
					       X509_LOOKUP_hash_dir());
		if (lookup == NULL)
			{
			BIO_printf(bio_err, "memory allocation failure\n");
			goto err;
			}
		i = X509_LOOKUP_add_dir(lookup, ca_path, X509_FILETYPE_PEM);
		if (!i)
			{
			BIO_printf(bio_err, "Error loading directory %s\n",
				   ca_path);
			goto err;
			}
		}
	if (ca_file)
		{
		lookup = X509_STORE_add_lookup(cert_ctx, X509_LOOKUP_file());
		if (lookup == NULL)
			{
			BIO_printf(bio_err, "memory allocation failure\n");
			goto err;
			}
		i = X509_LOOKUP_load_file(lookup, ca_file, X509_FILETYPE_PEM);
		if (!i)
			{
			BIO_printf(bio_err, "Error loading file %s\n", ca_file);
			goto err;
			}
		}
	return cert_ctx;
 err:
	X509_STORE_free(cert_ctx);
	return NULL;
	}
['static X509_STORE *create_cert_store(char *ca_path, char *ca_file)\n\t{\n\tX509_STORE *cert_ctx = NULL;\n\tX509_LOOKUP *lookup = NULL;\n\tint i;\n\tcert_ctx = X509_STORE_new();\n\tX509_STORE_set_verify_cb_func(cert_ctx, verify_cb);\n\tif (ca_path)\n\t\t{\n\t\tlookup = X509_STORE_add_lookup(cert_ctx,\n\t\t\t\t\t       X509_LOOKUP_hash_dir());\n\t\tif (lookup == NULL)\n\t\t\t{\n\t\t\tBIO_printf(bio_err, "memory allocation failure\\n");\n\t\t\tgoto err;\n\t\t\t}\n\t\ti = X509_LOOKUP_add_dir(lookup, ca_path, X509_FILETYPE_PEM);\n\t\tif (!i)\n\t\t\t{\n\t\t\tBIO_printf(bio_err, "Error loading directory %s\\n",\n\t\t\t\t   ca_path);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\tif (ca_file)\n\t\t{\n\t\tlookup = X509_STORE_add_lookup(cert_ctx, X509_LOOKUP_file());\n\t\tif (lookup == NULL)\n\t\t\t{\n\t\t\tBIO_printf(bio_err, "memory allocation failure\\n");\n\t\t\tgoto err;\n\t\t\t}\n\t\ti = X509_LOOKUP_load_file(lookup, ca_file, X509_FILETYPE_PEM);\n\t\tif (!i)\n\t\t\t{\n\t\t\tBIO_printf(bio_err, "Error loading file %s\\n", ca_file);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\treturn cert_ctx;\n err:\n\tX509_STORE_free(cert_ctx);\n\treturn NULL;\n\t}', 'X509_STORE *X509_STORE_new(void)\n\t{\n\tX509_STORE *ret;\n\tif ((ret=(X509_STORE *)OPENSSL_malloc(sizeof(X509_STORE))) == NULL)\n\t\treturn NULL;\n\tret->objs = sk_X509_OBJECT_new(x509_object_cmp);\n\tret->cache=1;\n\tret->get_cert_methods=sk_X509_LOOKUP_new_null();\n\tret->verify=0;\n\tret->verify_cb=0;\n\tif ((ret->param = X509_VERIFY_PARAM_new()) == NULL)\n\t\treturn NULL;\n\tret->get_issuer = 0;\n\tret->check_issued = 0;\n\tret->check_revocation = 0;\n\tret->get_crl = 0;\n\tret->check_crl = 0;\n\tret->cert_crl = 0;\n\tret->cleanup = 0;\n\tCRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data);\n\tret->references=1;\n\treturn ret;\n\t}', 'void *CRYPTO_malloc(int num, const char *file, int line)\n\t{\n\tvoid *ret = NULL;\n\textern unsigned char cleanse_ctr;\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        if(ret && (num > 2048))\n                ((unsigned char *)ret)[0] = cleanse_ctr;\n\treturn ret;\n\t}']