apps/apps.c:1571: error: NULL_DEREFERENCE
  pointer `store` last assigned on line 1549 could be null and is dereferenced by call to `X509_STORE_free()` at line 1571, column 2.
Showing all 20 steps of the trace


apps/apps.c:1545:1: start of procedure setup_verify()
1543.   }
1544.   
1545. > X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)
1546.   {
1547.   	X509_STORE *store;

apps/apps.c:1549:7: 
1547.   	X509_STORE *store;
1548.   	X509_LOOKUP *lookup;
1549. > 	if(!(store = X509_STORE_new())) goto end;
1550.   	lookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());
1551.   	if (lookup == NULL) goto end;

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:295:1: start of procedure CRYPTO_malloc()
    293.   	}
    294.   
    295. > void *CRYPTO_malloc(int num, const char *file, int line)
    296.   	{
    297.   	void *ret = NULL;

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

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

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

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

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

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

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

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

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

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:212:2: return from a call to X509_STORE_new
  210.   	ret->references=1;
  211.   	return ret;
  212.   	}
          ^
  213.   
  214.   static void cleanup(X509_OBJECT *a)

apps/apps.c:1549:7: Taking true branch
1547.   	X509_STORE *store;
1548.   	X509_LOOKUP *lookup;
1549.   	if(!(store = X509_STORE_new())) goto end;
              ^
1550.   	lookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());
1551.   	if (lookup == NULL) goto end;

apps/apps.c:1570:2: 
1568.   	ERR_clear_error();
1569.   	return store;
1570. > 	end:
1571.   	X509_STORE_free(store);
1572.   	return NULL;

apps/apps.c:1571:2: 
1569.   	return store;
1570.   	end:
1571. > 	X509_STORE_free(store);
1572.   	return NULL;
1573.   }

X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)
{
	X509_STORE *store;
	X509_LOOKUP *lookup;
	if(!(store = X509_STORE_new())) goto end;
	lookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());
	if (lookup == NULL) goto end;
	if (CAfile) {
		if(!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM)) {
			BIO_printf(bp, "Error loading file %s\n", CAfile);
			goto end;
		}
	} else X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);
	lookup=X509_STORE_add_lookup(store,X509_LOOKUP_hash_dir());
	if (lookup == NULL) goto end;
	if (CApath) {
		if(!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM)) {
			BIO_printf(bp, "Error loading directory %s\n", CApath);
			goto end;
		}
	} else X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
	ERR_clear_error();
	return store;
	end:
	X509_STORE_free(store);
	return NULL;
}
['X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)\n{\n\tX509_STORE *store;\n\tX509_LOOKUP *lookup;\n\tif(!(store = X509_STORE_new())) goto end;\n\tlookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());\n\tif (lookup == NULL) goto end;\n\tif (CAfile) {\n\t\tif(!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM)) {\n\t\t\tBIO_printf(bp, "Error loading file %s\\n", CAfile);\n\t\t\tgoto end;\n\t\t}\n\t} else X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);\n\tlookup=X509_STORE_add_lookup(store,X509_LOOKUP_hash_dir());\n\tif (lookup == NULL) goto end;\n\tif (CApath) {\n\t\tif(!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM)) {\n\t\t\tBIO_printf(bp, "Error loading directory %s\\n", CApath);\n\t\t\tgoto end;\n\t\t}\n\t} else X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);\n\tERR_clear_error();\n\treturn store;\n\tend:\n\tX509_STORE_free(store);\n\treturn NULL;\n}', '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->lookup_certs = 0;\n\tret->lookup_crls = 0;\n\tret->cleanup = 0;\n\tif (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data))\n\t\t{\n\t\tsk_X509_OBJECT_free(ret->objs);\n\t\tOPENSSL_free(ret);\n\t\treturn NULL;\n\t\t}\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\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}']