crypto/pkcs7/pk7_asn1.c:94: error: NULL_DEREFERENCE
  pointer `p7` last assigned on line 89 could be null and is dereferenced by call to `PKCS7_stream()` at line 94, column 7.
Showing all 10 steps of the trace


crypto/pkcs7/pk7_asn1.c:81:1: start of procedure pk7_cb()
79.   
80.   /* PKCS#7 streaming support */
81. > static int pk7_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
82.   							void *exarg)
83.   {

crypto/pkcs7/pk7_asn1.c:84:2: 
82.   							void *exarg)
83.   {
84. > 	ASN1_STREAM_ARG *sarg = exarg;
85.   	PKCS7 *p7;
86.   	if (pval)

crypto/pkcs7/pk7_asn1.c:86:6: Taking false branch
84.   	ASN1_STREAM_ARG *sarg = exarg;
85.   	PKCS7 *p7;
86.   	if (pval)
           ^
87.   		p7 = (PKCS7 *)*pval;
88.   	else

crypto/pkcs7/pk7_asn1.c:89:3: 
87.   		p7 = (PKCS7 *)*pval;
88.   	else
89. > 		p7 = NULL;
90.   	switch(operation)
91.   		{

crypto/pkcs7/pk7_asn1.c:90:2: 
88.   	else
89.   		p7 = NULL;
90. > 	switch(operation)
91.   		{
92.   

crypto/pkcs7/pk7_asn1.c:93:3: Switch condition is true. Entering switch case
91.   		{
92.   
93.   		case ASN1_OP_STREAM_PRE:
        ^
94.   		if (PKCS7_stream(&sarg->boundary, p7) <= 0)
95.   			return 0;

crypto/pkcs7/pk7_asn1.c:94:7: 
92.   
93.   		case ASN1_OP_STREAM_PRE:
94. > 		if (PKCS7_stream(&sarg->boundary, p7) <= 0)
95.   			return 0;
96.   		case ASN1_OP_DETACHED_PRE:

crypto/pkcs7/pk7_lib.c:623:1: start of procedure PKCS7_stream()
  621.   	}
  622.   
  623. > int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7)
  624.   	{
  625.   	ASN1_OCTET_STRING *os = NULL;

crypto/pkcs7/pk7_lib.c:625:2: 
  623.   int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7)
  624.   	{
  625. > 	ASN1_OCTET_STRING *os = NULL;
  626.   
  627.   	switch (OBJ_obj2nid(p7->type))

crypto/pkcs7/pk7_lib.c:627:2: 
  625.   	ASN1_OCTET_STRING *os = NULL;
  626.   
  627. > 	switch (OBJ_obj2nid(p7->type))
  628.   		{
  629.   		case NID_pkcs7_data:

static int pk7_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
							void *exarg)
{
	ASN1_STREAM_ARG *sarg = exarg;
	PKCS7 *p7;
	if (pval)
		p7 = (PKCS7 *)*pval;
	else
		p7 = NULL;
	switch(operation)
		{
		case ASN1_OP_STREAM_PRE:
		if (PKCS7_stream(&sarg->boundary, p7) <= 0)
			return 0;
		case ASN1_OP_DETACHED_PRE:
		sarg->ndef_bio = PKCS7_dataInit(p7, sarg->out);
		if (!sarg->ndef_bio)
			return 0;
		break;
		case ASN1_OP_STREAM_POST:
		case ASN1_OP_DETACHED_POST:
		if (PKCS7_dataFinal(p7, sarg->ndef_bio) <= 0)
			return 0;
		break;
		}
	return 1;
}
['static int pk7_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,\n\t\t\t\t\t\t\tvoid *exarg)\n{\n\tASN1_STREAM_ARG *sarg = exarg;\n\tPKCS7 *p7;\n\tif (pval)\n\t\tp7 = (PKCS7 *)*pval;\n\telse\n\t\tp7 = NULL;\n\tswitch(operation)\n\t\t{\n\t\tcase ASN1_OP_STREAM_PRE:\n\t\tif (PKCS7_stream(&sarg->boundary, p7) <= 0)\n\t\t\treturn 0;\n\t\tcase ASN1_OP_DETACHED_PRE:\n\t\tsarg->ndef_bio = PKCS7_dataInit(p7, sarg->out);\n\t\tif (!sarg->ndef_bio)\n\t\t\treturn 0;\n\t\tbreak;\n\t\tcase ASN1_OP_STREAM_POST:\n\t\tcase ASN1_OP_DETACHED_POST:\n\t\tif (PKCS7_dataFinal(p7, sarg->ndef_bio) <= 0)\n\t\t\treturn 0;\n\t\tbreak;\n\t\t}\n\treturn 1;\n}', 'int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7)\n\t{\n\tASN1_OCTET_STRING *os = NULL;\n\tswitch (OBJ_obj2nid(p7->type))\n\t\t{\n\t\tcase NID_pkcs7_data:\n\t\tos = p7->d.data;\n\t\tbreak;\n\t\tcase NID_pkcs7_signedAndEnveloped:\n\t\tos = p7->d.signed_and_enveloped->enc_data->enc_data;\n\t\tif (os == NULL)\n\t\t\t{\n\t\t\tos=M_ASN1_OCTET_STRING_new();\n\t\t\tp7->d.signed_and_enveloped->enc_data->enc_data=os;\n\t\t\t}\n\t\tbreak;\n\t\tcase NID_pkcs7_enveloped:\n\t\tos = p7->d.enveloped->enc_data->enc_data;\n\t\tif (os == NULL)\n\t\t\t{\n\t\t\tos=M_ASN1_OCTET_STRING_new();\n\t\t\tp7->d.enveloped->enc_data->enc_data=os;\n\t\t\t}\n\t\tbreak;\n\t\tcase NID_pkcs7_signed:\n\t\tos=p7->d.sign->contents->d.data;\n\t\tbreak;\n\t\tdefault:\n\t\tos = NULL;\n\t\tbreak;\n\t\t}\n\tif (os == NULL)\n\t\treturn 0;\n\tos->flags |= ASN1_STRING_FLAG_NDEF;\n\t*boundary = &os->data;\n\treturn 1;\n\t}']