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


apps/ts.c:1008:1: start of procedure create_verify_ctx()
1006.   	}
1007.   
1008. > static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest, 
1009.   					char *queryfile, 
1010.   					char *ca_path, char *ca_file,

apps/ts.c:1013:2: 
1011.   					char *untrusted)
1012.   	{
1013. > 	TS_VERIFY_CTX *ctx = NULL;
1014.   	BIO *input = NULL;
1015.   	TS_REQ *request = NULL;

apps/ts.c:1014:2: 
1012.   	{
1013.   	TS_VERIFY_CTX *ctx = NULL;
1014. > 	BIO *input = NULL;
1015.   	TS_REQ *request = NULL;
1016.   	int ret = 0;

apps/ts.c:1015:2: 
1013.   	TS_VERIFY_CTX *ctx = NULL;
1014.   	BIO *input = NULL;
1015. > 	TS_REQ *request = NULL;
1016.   	int ret = 0;
1017.   

apps/ts.c:1016:2: 
1014.   	BIO *input = NULL;
1015.   	TS_REQ *request = NULL;
1016. > 	int ret = 0;
1017.   
1018.   	if (data != NULL || digest != NULL)

apps/ts.c:1018:6: Taking false branch
1016.   	int ret = 0;
1017.   
1018.   	if (data != NULL || digest != NULL)
             ^
1019.   		{
1020.   		if (!(ctx = TS_VERIFY_CTX_new())) goto err;

apps/ts.c:1018:22: Taking false branch
1016.   	int ret = 0;
1017.   
1018.   	if (data != NULL || digest != NULL)
                             ^
1019.   		{
1020.   		if (!(ctx = TS_VERIFY_CTX_new())) goto err;

apps/ts.c:1041:11: Taking false branch
1039.   		
1040.   		}
1041.   	else if (queryfile != NULL)
                  ^
1042.   		{
1043.   		/* The request has just to be read, decoded and converted to

apps/ts.c:1051:2: 
1049.   
1050.   	/* Add the signature verification flag and arguments. */
1051. > 	ctx->flags |= TS_VFY_SIGNATURE;
1052.   
1053.   	/* 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}']