apps/ts.c:1046: error: NULL_DEREFERENCE
  pointer `ctx` last assigned on line 1008 could be null and is dereferenced at line 1046, column 2.
Showing all 9 steps of the trace


apps/ts.c:1003:1: start of procedure create_verify_ctx()
1001.   	}
1002.   
1003. > static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest, 
1004.   					char *queryfile, 
1005.   					char *ca_path, char *ca_file,

apps/ts.c:1008:2: 
1006.   					char *untrusted)
1007.   	{
1008. > 	TS_VERIFY_CTX *ctx = NULL;
1009.   	BIO *input = NULL;
1010.   	TS_REQ *request = NULL;

apps/ts.c:1009:2: 
1007.   	{
1008.   	TS_VERIFY_CTX *ctx = NULL;
1009. > 	BIO *input = NULL;
1010.   	TS_REQ *request = NULL;
1011.   	int ret = 0;

apps/ts.c:1010:2: 
1008.   	TS_VERIFY_CTX *ctx = NULL;
1009.   	BIO *input = NULL;
1010. > 	TS_REQ *request = NULL;
1011.   	int ret = 0;
1012.   

apps/ts.c:1011:2: 
1009.   	BIO *input = NULL;
1010.   	TS_REQ *request = NULL;
1011. > 	int ret = 0;
1012.   
1013.   	if (data != NULL || digest != NULL)

apps/ts.c:1013:6: Taking false branch
1011.   	int ret = 0;
1012.   
1013.   	if (data != NULL || digest != NULL)
             ^
1014.   		{
1015.   		if (!(ctx = TS_VERIFY_CTX_new())) goto err;

apps/ts.c:1013:22: Taking false branch
1011.   	int ret = 0;
1012.   
1013.   	if (data != NULL || digest != NULL)
                             ^
1014.   		{
1015.   		if (!(ctx = TS_VERIFY_CTX_new())) goto err;

apps/ts.c:1036:11: Taking false branch
1034.   		
1035.   		}
1036.   	else if (queryfile != NULL)
                  ^
1037.   		{
1038.   		/* The request has just to be read, decoded and converted to

apps/ts.c:1046:2: 
1044.   
1045.   	/* Add the signature verification flag and arguments. */
1046. > 	ctx->flags |= TS_VFY_SIGNATURE;
1047.   
1048.   	/* Initialising the X509_STORE object. */

static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,
					char *queryfile,
					char *ca_path, char *ca_file,
					char *untrusted)
	{
	TS_VERIFY_CTX *ctx = NULL;
	BIO *input = NULL;
	TS_REQ *request = NULL;
	int ret = 0;
	if (data != NULL || digest != NULL)
		{
		if (!(ctx = TS_VERIFY_CTX_new())) goto err;
		ctx->flags = TS_VFY_VERSION | TS_VFY_SIGNER;
		if (data != NULL)
			{
			ctx->flags |= TS_VFY_DATA;
			if (!(ctx->data = BIO_new_file(data, "rb"))) goto err;
			}
		else if (digest != NULL)
			{
			long imprint_len;
			ctx->flags |= TS_VFY_IMPRINT;
			if (!(ctx->imprint = string_to_hex(digest,
							   &imprint_len)))
				{
				BIO_printf(bio_err, "invalid digest string\n");
				goto err;
				}
			ctx->imprint_len = imprint_len;
			}
		}
	else if (queryfile != NULL)
		{
		if (!(input = BIO_new_file(queryfile, "rb"))) goto err;
		if (!(request = d2i_TS_REQ_bio(input, NULL))) goto err;
		if (!(ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL))) goto err;
		}
	ctx->flags |= TS_VFY_SIGNATURE;
	if (!(ctx->store = create_cert_store(ca_path, ca_file))) goto err;
	if (untrusted && !(ctx->certs = TS_CONF_load_certs(untrusted)))
		goto err;
	ret = 1;
 err:
	if (!ret)
		{
		TS_VERIFY_CTX_free(ctx);
		ctx = NULL;
		}
	BIO_free_all(input);
	TS_REQ_free(request);
	return ctx;
	}
['static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,\n\t\t\t\t\tchar *queryfile,\n\t\t\t\t\tchar *ca_path, char *ca_file,\n\t\t\t\t\tchar *untrusted)\n\t{\n\tTS_VERIFY_CTX *ctx = NULL;\n\tBIO *input = NULL;\n\tTS_REQ *request = NULL;\n\tint ret = 0;\n\tif (data != NULL || digest != NULL)\n\t\t{\n\t\tif (!(ctx = TS_VERIFY_CTX_new())) goto err;\n\t\tctx->flags = TS_VFY_VERSION | TS_VFY_SIGNER;\n\t\tif (data != NULL)\n\t\t\t{\n\t\t\tctx->flags |= TS_VFY_DATA;\n\t\t\tif (!(ctx->data = BIO_new_file(data, "rb"))) goto err;\n\t\t\t}\n\t\telse if (digest != NULL)\n\t\t\t{\n\t\t\tlong imprint_len;\n\t\t\tctx->flags |= TS_VFY_IMPRINT;\n\t\t\tif (!(ctx->imprint = string_to_hex(digest,\n\t\t\t\t\t\t\t   &imprint_len)))\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err, "invalid digest string\\n");\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tctx->imprint_len = imprint_len;\n\t\t\t}\n\t\t}\n\telse if (queryfile != NULL)\n\t\t{\n\t\tif (!(input = BIO_new_file(queryfile, "rb"))) goto err;\n\t\tif (!(request = d2i_TS_REQ_bio(input, NULL))) goto err;\n\t\tif (!(ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL))) goto err;\n\t\t}\n\tctx->flags |= TS_VFY_SIGNATURE;\n\tif (!(ctx->store = create_cert_store(ca_path, ca_file))) goto err;\n\tif (untrusted && !(ctx->certs = TS_CONF_load_certs(untrusted)))\n\t\tgoto err;\n\tret = 1;\n err:\n\tif (!ret)\n\t\t{\n\t\tTS_VERIFY_CTX_free(ctx);\n\t\tctx = NULL;\n\t\t}\n\tBIO_free_all(input);\n\tTS_REQ_free(request);\n\treturn ctx;\n\t}']