crypto/asn1/asn1_gen.c:461: error: NULL_DEREFERENCE
  pointer `sk` last assigned on line 448 could be null and is dereferenced by call to `sk_push()` at line 461, column 4.
Showing all 56 steps of the trace


crypto/asn1/asn1_gen.c:440:1: start of procedure asn1_multi()
438.   /* Handle multiple types: SET and SEQUENCE */
439.   
440. > static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
441.   	{
442.   	ASN1_TYPE *ret = NULL;

crypto/asn1/asn1_gen.c:442:2: 
440.   static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
441.   	{
442. > 	ASN1_TYPE *ret = NULL;
443.   	STACK_OF(ASN1_TYPE) *sk = NULL;
444.   	STACK_OF(CONF_VALUE) *sect = NULL;

crypto/asn1/asn1_gen.c:443:2: 
441.   	{
442.   	ASN1_TYPE *ret = NULL;
443. > 	STACK_OF(ASN1_TYPE) *sk = NULL;
444.   	STACK_OF(CONF_VALUE) *sect = NULL;
445.   	unsigned char *der = NULL, *p;

crypto/asn1/asn1_gen.c:444:2: 
442.   	ASN1_TYPE *ret = NULL;
443.   	STACK_OF(ASN1_TYPE) *sk = NULL;
444. > 	STACK_OF(CONF_VALUE) *sect = NULL;
445.   	unsigned char *der = NULL, *p;
446.   	int derlen;

crypto/asn1/asn1_gen.c:445:2: 
443.   	STACK_OF(ASN1_TYPE) *sk = NULL;
444.   	STACK_OF(CONF_VALUE) *sect = NULL;
445. > 	unsigned char *der = NULL, *p;
446.   	int derlen;
447.   	int i, is_set;

crypto/asn1/asn1_gen.c:448:2: 
446.   	int derlen;
447.   	int i, is_set;
448. > 	sk = sk_ASN1_TYPE_new_null();
449.   	if (section)
450.   		{

crypto/stack/stack.c:115:1: start of procedure sk_new_null()
  113.   	}
  114.   
  115. > STACK *sk_new_null(void)
  116.   	{
  117.   	return sk_new((int (*)(const char * const *, const char * const *))0);

crypto/stack/stack.c:117:2: 
  115.   STACK *sk_new_null(void)
  116.   	{
  117. > 	return sk_new((int (*)(const char * const *, const char * const *))0);
  118.   	}
  119.   

crypto/stack/stack.c:120:1: start of procedure sk_new()
    118.   	}
    119.   
    120. > STACK *sk_new(int (*c)(const char * const *, const char * const *))
    121.   	{
    122.   	STACK *ret;

crypto/stack/stack.c:125:6: 
    123.   	int i;
    124.   
    125. > 	if ((ret=(STACK *)OPENSSL_malloc(sizeof(STACK))) == NULL)
    126.   		goto err;
    127.   	if ((ret->data=(char **)OPENSSL_malloc(sizeof(char *)*MIN_NODES)) == NULL)

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/stack/stack.c:125:6: Taking true branch
    123.   	int i;
    124.   
    125.   	if ((ret=(STACK *)OPENSSL_malloc(sizeof(STACK))) == NULL)
                ^
    126.   		goto err;
    127.   	if ((ret->data=(char **)OPENSSL_malloc(sizeof(char *)*MIN_NODES)) == NULL)

crypto/stack/stack.c:136:1: 
    134.   	ret->sorted=0;
    135.   	return(ret);
    136. > err:
    137.   	if(ret)
    138.   		OPENSSL_free(ret);

crypto/stack/stack.c:137:5: Taking false branch
    135.   	return(ret);
    136.   err:
    137.   	if(ret)
               ^
    138.   		OPENSSL_free(ret);
    139.   	return(NULL);

crypto/stack/stack.c:139:2: 
    137.   	if(ret)
    138.   		OPENSSL_free(ret);
    139. > 	return(NULL);
    140.   	}
    141.   

crypto/stack/stack.c:140:2: return from a call to sk_new
    138.   		OPENSSL_free(ret);
    139.   	return(NULL);
    140.   	}
            ^
    141.   
    142.   int sk_insert(STACK *st, char *data, int loc)

crypto/stack/stack.c:118:2: return from a call to sk_new_null
  116.   	{
  117.   	return sk_new((int (*)(const char * const *, const char * const *))0);
  118.   	}
          ^
  119.   
  120.   STACK *sk_new(int (*c)(const char * const *, const char * const *))

crypto/asn1/asn1_gen.c:449:6: Taking true branch
447.   	int i, is_set;
448.   	sk = sk_ASN1_TYPE_new_null();
449.   	if (section)
            ^
450.   		{
451.   		if (!cnf)

crypto/asn1/asn1_gen.c:451:8: Taking false branch
449.   	if (section)
450.   		{
451.   		if (!cnf)
              ^
452.   			goto bad;
453.   		sect = X509V3_get_section(cnf, (char *)section);

crypto/asn1/asn1_gen.c:453:3: 
451.   		if (!cnf)
452.   			goto bad;
453. > 		sect = X509V3_get_section(cnf, (char *)section);
454.   		if (!sect)
455.   			goto bad;

crypto/x509v3/v3_conf.c:396:1: start of procedure X509V3_get_section()
  394.   	}
  395.   
  396. > STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section)
  397.   	{
  398.   	if(!ctx->db || !ctx->db_meth || !ctx->db_meth->get_section)

crypto/x509v3/v3_conf.c:398:6: Taking false branch
  396.   STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section)
  397.   	{
  398.   	if(!ctx->db || !ctx->db_meth || !ctx->db_meth->get_section)
              ^
  399.   		{
  400.   		X509V3err(X509V3_F_X509V3_GET_SECTION,X509V3_R_OPERATION_NOT_DEFINED);

crypto/x509v3/v3_conf.c:398:18: Taking false branch
  396.   STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section)
  397.   	{
  398.   	if(!ctx->db || !ctx->db_meth || !ctx->db_meth->get_section)
                          ^
  399.   		{
  400.   		X509V3err(X509V3_F_X509V3_GET_SECTION,X509V3_R_OPERATION_NOT_DEFINED);

crypto/x509v3/v3_conf.c:398:35: Taking false branch
  396.   STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section)
  397.   	{
  398.   	if(!ctx->db || !ctx->db_meth || !ctx->db_meth->get_section)
                                           ^
  399.   		{
  400.   		X509V3err(X509V3_F_X509V3_GET_SECTION,X509V3_R_OPERATION_NOT_DEFINED);

crypto/x509v3/v3_conf.c:403:6: Taking true branch
  401.   		return NULL;
  402.   		}
  403.   	if (ctx->db_meth->get_section)
              ^
  404.   			return ctx->db_meth->get_section(ctx->db, section);
  405.   	return NULL;

crypto/x509v3/v3_conf.c:404:4: Skipping __function_pointer__(): unresolved function pointer
  402.   		}
  403.   	if (ctx->db_meth->get_section)
  404.   			return ctx->db_meth->get_section(ctx->db, section);
            ^
  405.   	return NULL;
  406.   	}

crypto/x509v3/v3_conf.c:406:2: return from a call to X509V3_get_section
  404.   			return ctx->db_meth->get_section(ctx->db, section);
  405.   	return NULL;
  406.   	}
          ^
  407.   
  408.   void X509V3_string_free(X509V3_CTX *ctx, char *str)

crypto/asn1/asn1_gen.c:454:8: Taking false branch
452.   			goto bad;
453.   		sect = X509V3_get_section(cnf, (char *)section);
454.   		if (!sect)
              ^
455.   			goto bad;
456.   		for (i = 0; i < sk_CONF_VALUE_num(sect); i++)

crypto/asn1/asn1_gen.c:456:8: 
454.   		if (!sect)
455.   			goto bad;
456. > 		for (i = 0; i < sk_CONF_VALUE_num(sect); i++)
457.   			{
458.   			ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);

crypto/asn1/asn1_gen.c:456:15: 
454.   		if (!sect)
455.   			goto bad;
456. > 		for (i = 0; i < sk_CONF_VALUE_num(sect); i++)
457.   			{
458.   			ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);

crypto/stack/stack.c:301:1: start of procedure sk_num()
  299.   	}
  300.   
  301. > int sk_num(const STACK *st)
  302.   {
  303.   	if(st == NULL) return -1;

crypto/stack/stack.c:303:5: Taking false branch
  301.   int sk_num(const STACK *st)
  302.   {
  303.   	if(st == NULL) return -1;
             ^
  304.   	return st->num;
  305.   }

crypto/stack/stack.c:304:2: 
  302.   {
  303.   	if(st == NULL) return -1;
  304. > 	return st->num;
  305.   }
  306.   

crypto/stack/stack.c:305:1: return from a call to sk_num
  303.   	if(st == NULL) return -1;
  304.   	return st->num;
  305. > }
  306.   
  307.   char *sk_value(const STACK *st, int i)

crypto/asn1/asn1_gen.c:456:15: Loop condition is true. Entering loop body
454.   		if (!sect)
455.   			goto bad;
456.   		for (i = 0; i < sk_CONF_VALUE_num(sect); i++)
                     ^
457.   			{
458.   			ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);

crypto/asn1/asn1_gen.c:458:4: 
456.   		for (i = 0; i < sk_CONF_VALUE_num(sect); i++)
457.   			{
458. > 			ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);
459.   			if (!typ)
460.   				goto bad;

crypto/stack/stack.c:307:1: start of procedure sk_value()
  305.   }
  306.   
  307. > char *sk_value(const STACK *st, int i)
  308.   {
  309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:309:6: Taking false branch
  307.   char *sk_value(const STACK *st, int i)
  308.   {
  309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  310.   	return st->data[i];
  311.   }

crypto/stack/stack.c:309:13: Taking false branch
  307.   char *sk_value(const STACK *st, int i)
  308.   {
  309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  310.   	return st->data[i];
  311.   }

crypto/stack/stack.c:309:24: Taking false branch
  307.   char *sk_value(const STACK *st, int i)
  308.   {
  309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                                ^
  310.   	return st->data[i];
  311.   }

crypto/stack/stack.c:310:2: 
  308.   {
  309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  310. > 	return st->data[i];
  311.   }
  312.   

crypto/stack/stack.c:311:1: return from a call to sk_value
  309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  310.   	return st->data[i];
  311. > }
  312.   
  313.   char *sk_set(STACK *st, int i, char *value)

crypto/asn1/asn1_gen.c:458:4: Skipping ASN1_generate_v3(): function or method not found
456.   		for (i = 0; i < sk_CONF_VALUE_num(sect); i++)
457.   			{
458.   			ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);
          ^
459.   			if (!typ)
460.   				goto bad;

crypto/asn1/asn1_gen.c:459:9: Taking false branch
457.   			{
458.   			ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);
459.   			if (!typ)
               ^
460.   				goto bad;
461.   			sk_ASN1_TYPE_push(sk, typ);

crypto/asn1/asn1_gen.c:461:4: 
459.   			if (!typ)
460.   				goto bad;
461. > 			sk_ASN1_TYPE_push(sk, typ);
462.   			}
463.   		}

crypto/stack/stack.c:251:1: start of procedure sk_push()
  249.   	}
  250.   
  251. > int sk_push(STACK *st, char *data)
  252.   	{
  253.   	return(sk_insert(st,data,st->num));

crypto/stack/stack.c:253:2: Skipping sk_insert(): empty list of specs
  251.   int sk_push(STACK *st, char *data)
  252.   	{
  253.   	return(sk_insert(st,data,st->num));
          ^
  254.   	}
  255.   

static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
	{
	ASN1_TYPE *ret = NULL;
	STACK_OF(ASN1_TYPE) *sk = NULL;
	STACK_OF(CONF_VALUE) *sect = NULL;
	unsigned char *der = NULL, *p;
	int derlen;
	int i, is_set;
	sk = sk_ASN1_TYPE_new_null();
	if (section)
		{
		if (!cnf)
			goto bad;
		sect = X509V3_get_section(cnf, (char *)section);
		if (!sect)
			goto bad;
		for (i = 0; i < sk_CONF_VALUE_num(sect); i++)
			{
			ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);
			if (!typ)
				goto bad;
			sk_ASN1_TYPE_push(sk, typ);
			}
		}
	if (utype == V_ASN1_SET)
		is_set = 1;
	else
		is_set = 0;
	derlen = i2d_ASN1_SET_OF_ASN1_TYPE(sk, NULL, i2d_ASN1_TYPE, utype,
					   V_ASN1_UNIVERSAL, is_set);
	der = OPENSSL_malloc(derlen);
	p = der;
	i2d_ASN1_SET_OF_ASN1_TYPE(sk, &p, i2d_ASN1_TYPE, utype,
				  V_ASN1_UNIVERSAL, is_set);
	if (!(ret = ASN1_TYPE_new()))
		goto bad;
	if (!(ret->value.asn1_string = ASN1_STRING_type_new(utype)))
		goto bad;
	ret->type = utype;
	ret->value.asn1_string->data = der;
	ret->value.asn1_string->length = derlen;
	der = NULL;
	bad:
	if (der)
		OPENSSL_free(der);
	if (sk)
		sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
	if (sect)
		X509V3_section_free(cnf, sect);
	return ret;
	}
['static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)\n\t{\n\tASN1_TYPE *ret = NULL;\n\tSTACK_OF(ASN1_TYPE) *sk = NULL;\n\tSTACK_OF(CONF_VALUE) *sect = NULL;\n\tunsigned char *der = NULL, *p;\n\tint derlen;\n\tint i, is_set;\n\tsk = sk_ASN1_TYPE_new_null();\n\tif (section)\n\t\t{\n\t\tif (!cnf)\n\t\t\tgoto bad;\n\t\tsect = X509V3_get_section(cnf, (char *)section);\n\t\tif (!sect)\n\t\t\tgoto bad;\n\t\tfor (i = 0; i < sk_CONF_VALUE_num(sect); i++)\n\t\t\t{\n\t\t\tASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf);\n\t\t\tif (!typ)\n\t\t\t\tgoto bad;\n\t\t\tsk_ASN1_TYPE_push(sk, typ);\n\t\t\t}\n\t\t}\n\tif (utype == V_ASN1_SET)\n\t\tis_set = 1;\n\telse\n\t\tis_set = 0;\n\tderlen = i2d_ASN1_SET_OF_ASN1_TYPE(sk, NULL, i2d_ASN1_TYPE, utype,\n\t\t\t\t\t   V_ASN1_UNIVERSAL, is_set);\n\tder = OPENSSL_malloc(derlen);\n\tp = der;\n\ti2d_ASN1_SET_OF_ASN1_TYPE(sk, &p, i2d_ASN1_TYPE, utype,\n\t\t\t\t  V_ASN1_UNIVERSAL, is_set);\n\tif (!(ret = ASN1_TYPE_new()))\n\t\tgoto bad;\n\tif (!(ret->value.asn1_string = ASN1_STRING_type_new(utype)))\n\t\tgoto bad;\n\tret->type = utype;\n\tret->value.asn1_string->data = der;\n\tret->value.asn1_string->length = derlen;\n\tder = NULL;\n\tbad:\n\tif (der)\n\t\tOPENSSL_free(der);\n\tif (sk)\n\t\tsk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);\n\tif (sect)\n\t\tX509V3_section_free(cnf, sect);\n\treturn ret;\n\t}', 'STACK *sk_new_null(void)\n\t{\n\treturn sk_new((int (*)(const char * const *, const char * const *))0);\n\t}', 'STACK *sk_new(int (*c)(const char * const *, const char * const *))\n\t{\n\tSTACK *ret;\n\tint i;\n\tif ((ret=(STACK *)OPENSSL_malloc(sizeof(STACK))) == NULL)\n\t\tgoto err;\n\tif ((ret->data=(char **)OPENSSL_malloc(sizeof(char *)*MIN_NODES)) == NULL)\n\t\tgoto err;\n\tfor (i=0; i<MIN_NODES; i++)\n\t\tret->data[i]=NULL;\n\tret->comp=c;\n\tret->num_alloc=MIN_NODES;\n\tret->num=0;\n\tret->sorted=0;\n\treturn(ret);\nerr:\n\tif(ret)\n\t\tOPENSSL_free(ret);\n\treturn(NULL);\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}', 'STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section)\n\t{\n\tif(!ctx->db || !ctx->db_meth || !ctx->db_meth->get_section)\n\t\t{\n\t\tX509V3err(X509V3_F_X509V3_GET_SECTION,X509V3_R_OPERATION_NOT_DEFINED);\n\t\treturn NULL;\n\t\t}\n\tif (ctx->db_meth->get_section)\n\t\t\treturn ctx->db_meth->get_section(ctx->db, section);\n\treturn NULL;\n\t}', 'int sk_num(const STACK *st)\n{\n\tif(st == NULL) return -1;\n\treturn st->num;\n}', 'char *sk_value(const STACK *st, int i)\n{\n\tif(!st || (i < 0) || (i >= st->num)) return NULL;\n\treturn st->data[i];\n}', 'int sk_push(STACK *st, char *data)\n\t{\n\treturn(sk_insert(st,data,st->num));\n\t}']