crypto/x509/x509_v3.c:159: error: MEMORY_LEAK
  memory dynamically allocated by call to `sk_new()` at line 147, column 11 is not reachable after line 159, column 7.
Showing all 42 steps of the trace


crypto/x509/x509_v3.c:139:1: start of procedure X509v3_add_ext()
137.   	}
138.   
139. > STACK *X509v3_add_ext(STACK **x, X509_EXTENSION *ex, int loc)
140.   	{
141.   	X509_EXTENSION *new_ex=NULL;

crypto/x509/x509_v3.c:141:2: 
139.   STACK *X509v3_add_ext(STACK **x, X509_EXTENSION *ex, int loc)
140.   	{
141. > 	X509_EXTENSION *new_ex=NULL;
142.   	int n;
143.   	STACK *sk=NULL;

crypto/x509/x509_v3.c:143:2: 
141.   	X509_EXTENSION *new_ex=NULL;
142.   	int n;
143. > 	STACK *sk=NULL;
144.   
145.   	if ((x != NULL) && (*x == NULL))

crypto/x509/x509_v3.c:145:7: Taking true branch
143.   	STACK *sk=NULL;
144.   
145.   	if ((x != NULL) && (*x == NULL))
             ^
146.   		{
147.   		if ((sk=sk_new_null()) == NULL)

crypto/x509/x509_v3.c:145:22: Taking true branch
143.   	STACK *sk=NULL;
144.   
145.   	if ((x != NULL) && (*x == NULL))
                            ^
146.   		{
147.   		if ((sk=sk_new_null()) == NULL)

crypto/x509/x509_v3.c:147:7: 
145.   	if ((x != NULL) && (*x == NULL))
146.   		{
147. > 		if ((sk=sk_new_null()) == NULL)
148.   			goto err;
149.   		}

crypto/stack/stack.c:117:1: start of procedure sk_new()
  115.   	}
  116.   
  117. > STACK *sk_new(int (*c)())
  118.   	{
  119.   	STACK *ret;

crypto/stack/stack.c:122:6: Taking false branch
  120.   	int i;
  121.   
  122.   	if ((ret=(STACK *)Malloc(sizeof(STACK))) == NULL)
              ^
  123.   		goto err0;
  124.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)

crypto/stack/stack.c:124:6: Taking false branch
  122.   	if ((ret=(STACK *)Malloc(sizeof(STACK))) == NULL)
  123.   		goto err0;
  124.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
              ^
  125.   		goto err1;
  126.   	for (i=0; i<MIN_NODES; i++)

crypto/stack/stack.c:126:7: 
  124.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
  125.   		goto err1;
  126. > 	for (i=0; i<MIN_NODES; i++)
  127.   		ret->data[i]=NULL;
  128.   	ret->comp=c;

crypto/stack/stack.c:126:12: Loop condition is true. Entering loop body
  124.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
  125.   		goto err1;
  126.   	for (i=0; i<MIN_NODES; i++)
                    ^
  127.   		ret->data[i]=NULL;
  128.   	ret->comp=c;

crypto/stack/stack.c:127:3: 
  125.   		goto err1;
  126.   	for (i=0; i<MIN_NODES; i++)
  127. > 		ret->data[i]=NULL;
  128.   	ret->comp=c;
  129.   	ret->num_alloc=MIN_NODES;

crypto/stack/stack.c:126:25: 
  124.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
  125.   		goto err1;
  126. > 	for (i=0; i<MIN_NODES; i++)
  127.   		ret->data[i]=NULL;
  128.   	ret->comp=c;

crypto/stack/stack.c:126:12: Loop condition is false. Leaving loop
  124.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
  125.   		goto err1;
  126.   	for (i=0; i<MIN_NODES; i++)
                    ^
  127.   		ret->data[i]=NULL;
  128.   	ret->comp=c;

crypto/stack/stack.c:128:2: 
  126.   	for (i=0; i<MIN_NODES; i++)
  127.   		ret->data[i]=NULL;
  128. > 	ret->comp=c;
  129.   	ret->num_alloc=MIN_NODES;
  130.   	ret->num=0;

crypto/stack/stack.c:129:2: 
  127.   		ret->data[i]=NULL;
  128.   	ret->comp=c;
  129. > 	ret->num_alloc=MIN_NODES;
  130.   	ret->num=0;
  131.   	ret->sorted=0;

crypto/stack/stack.c:130:2: 
  128.   	ret->comp=c;
  129.   	ret->num_alloc=MIN_NODES;
  130. > 	ret->num=0;
  131.   	ret->sorted=0;
  132.   	return(ret);

crypto/stack/stack.c:131:2: 
  129.   	ret->num_alloc=MIN_NODES;
  130.   	ret->num=0;
  131. > 	ret->sorted=0;
  132.   	return(ret);
  133.   err1:

crypto/stack/stack.c:132:2: 
  130.   	ret->num=0;
  131.   	ret->sorted=0;
  132. > 	return(ret);
  133.   err1:
  134.   	Free((char *)ret);

crypto/stack/stack.c:137:2: return from a call to sk_new
  135.   err0:
  136.   	return(NULL);
  137.   	}
          ^
  138.   
  139.   int sk_insert(STACK *st, char *data, int loc)

crypto/x509/x509_v3.c:147:7: Taking false branch
145.   	if ((x != NULL) && (*x == NULL))
146.   		{
147.   		if ((sk=sk_new_null()) == NULL)
             ^
148.   			goto err;
149.   		}

crypto/x509/x509_v3.c:153:2: 
151.   		sk= *x;
152.   
153. > 	n=sk_num(sk);
154.   	if (loc > n) loc=n;
155.   	else if (loc < 0) loc=n;

crypto/x509/x509_v3.c:154:6: Taking true branch
152.   
153.   	n=sk_num(sk);
154.   	if (loc > n) loc=n;
            ^
155.   	else if (loc < 0) loc=n;
156.   

crypto/x509/x509_v3.c:154:15: 
152.   
153.   	n=sk_num(sk);
154. > 	if (loc > n) loc=n;
155.   	else if (loc < 0) loc=n;
156.   

crypto/x509/x509_v3.c:157:6: 
155.   	else if (loc < 0) loc=n;
156.   
157. > 	if ((new_ex=X509_EXTENSION_dup(ex)) == NULL)
158.   		goto err2;
159.   	if (!sk_insert(sk,(char *)new_ex,loc))

crypto/x509/x_all.c:128:1: start of procedure X509_EXTENSION_dup()
  126.   	}
  127.   
  128. > X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex)
  129.   	{
  130.   	return((X509_EXTENSION *)ASN1_dup(

crypto/x509/x_all.c:130:2: 
  128.   X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex)
  129.   	{
  130. > 	return((X509_EXTENSION *)ASN1_dup(
  131.   		(int (*)())i2d_X509_EXTENSION,
  132.   		(char *(*)())d2i_X509_EXTENSION,(char *)ex));

crypto/asn1/a_dup.c:65:1: start of procedure ASN1_dup()
    63.   #define READ_CHUNK   2048
    64.   
    65. > char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x)
    66.   	{
    67.   	unsigned char *b,*p;

crypto/asn1/a_dup.c:71:6: Taking false branch
    69.   	char *ret;
    70.   
    71.   	if (x == NULL) return(NULL);
               ^
    72.   
    73.   	i=(long)i2d(x,NULL);

crypto/asn1/a_dup.c:73:2: Skipping __function_pointer__(): unresolved function pointer
    71.   	if (x == NULL) return(NULL);
    72.   
    73.   	i=(long)i2d(x,NULL);
           ^
    74.   	b=(unsigned char *)Malloc((unsigned int)i+10);
    75.   	if (b == NULL)

crypto/asn1/a_dup.c:74:2: 
    72.   
    73.   	i=(long)i2d(x,NULL);
    74. > 	b=(unsigned char *)Malloc((unsigned int)i+10);
    75.   	if (b == NULL)
    76.   		{ ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }

crypto/asn1/a_dup.c:75:6: Taking false branch
    73.   	i=(long)i2d(x,NULL);
    74.   	b=(unsigned char *)Malloc((unsigned int)i+10);
    75.   	if (b == NULL)
               ^
    76.   		{ ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }
    77.   	p= b;

crypto/asn1/a_dup.c:77:2: 
    75.   	if (b == NULL)
    76.   		{ ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }
    77. > 	p= b;
    78.   	i=i2d(x,&p);
    79.   	p= b;

crypto/asn1/a_dup.c:78:2: Skipping __function_pointer__(): unresolved function pointer
    76.   		{ ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }
    77.   	p= b;
    78.   	i=i2d(x,&p);
           ^
    79.   	p= b;
    80.   	ret=d2i(NULL,&p,i);

crypto/asn1/a_dup.c:79:2: 
    77.   	p= b;
    78.   	i=i2d(x,&p);
    79. > 	p= b;
    80.   	ret=d2i(NULL,&p,i);
    81.   	Free((char *)b);

crypto/asn1/a_dup.c:80:2: Skipping __function_pointer__(): unresolved function pointer
    78.   	i=i2d(x,&p);
    79.   	p= b;
    80.   	ret=d2i(NULL,&p,i);
           ^
    81.   	Free((char *)b);
    82.   	return(ret);

crypto/asn1/a_dup.c:81:2: 
    79.   	p= b;
    80.   	ret=d2i(NULL,&p,i);
    81. > 	Free((char *)b);
    82.   	return(ret);
    83.   	}

crypto/asn1/a_dup.c:82:2: 
    80.   	ret=d2i(NULL,&p,i);
    81.   	Free((char *)b);
    82. > 	return(ret);
    83.   	}

crypto/asn1/a_dup.c:83:2: return from a call to ASN1_dup
    81.   	Free((char *)b);
    82.   	return(ret);
    83.   	}
           ^

crypto/x509/x_all.c:133:2: return from a call to X509_EXTENSION_dup
  131.   		(int (*)())i2d_X509_EXTENSION,
  132.   		(char *(*)())d2i_X509_EXTENSION,(char *)ex));
  133.   	}
          ^
  134.   
  135.   #ifndef NO_FP_API

crypto/x509/x509_v3.c:157:6: Taking false branch
155.   	else if (loc < 0) loc=n;
156.   
157.   	if ((new_ex=X509_EXTENSION_dup(ex)) == NULL)
            ^
158.   		goto err2;
159.   	if (!sk_insert(sk,(char *)new_ex,loc))

crypto/x509/x509_v3.c:159:7: Skipping sk_insert(): empty list of specs
157.   	if ((new_ex=X509_EXTENSION_dup(ex)) == NULL)
158.   		goto err2;
159.   	if (!sk_insert(sk,(char *)new_ex,loc))
             ^
160.   		goto err;
161.   	if ((x != NULL) && (*x == NULL))

STACK *X509v3_add_ext(STACK **x, X509_EXTENSION *ex, int loc)
	{
	X509_EXTENSION *new_ex=NULL;
	int n;
	STACK *sk=NULL;
	if ((x != NULL) && (*x == NULL))
		{
		if ((sk=sk_new_null()) == NULL)
			goto err;
		}
	else
		sk= *x;
	n=sk_num(sk);
	if (loc > n) loc=n;
	else if (loc < 0) loc=n;
	if ((new_ex=X509_EXTENSION_dup(ex)) == NULL)
		goto err2;
	if (!sk_insert(sk,(char *)new_ex,loc))
		goto err;
	if ((x != NULL) && (*x == NULL))
		*x=sk;
	return(sk);
err:
	X509err(X509_F_X509V3_ADD_EXT,ERR_R_MALLOC_FAILURE);
err2:
	if (new_ex != NULL) X509_EXTENSION_free(new_ex);
	if (sk != NULL) sk_free(sk);
	return(NULL);
	}
['STACK *X509v3_add_ext(STACK **x, X509_EXTENSION *ex, int loc)\n\t{\n\tX509_EXTENSION *new_ex=NULL;\n\tint n;\n\tSTACK *sk=NULL;\n\tif ((x != NULL) && (*x == NULL))\n\t\t{\n\t\tif ((sk=sk_new_null()) == NULL)\n\t\t\tgoto err;\n\t\t}\n\telse\n\t\tsk= *x;\n\tn=sk_num(sk);\n\tif (loc > n) loc=n;\n\telse if (loc < 0) loc=n;\n\tif ((new_ex=X509_EXTENSION_dup(ex)) == NULL)\n\t\tgoto err2;\n\tif (!sk_insert(sk,(char *)new_ex,loc))\n\t\tgoto err;\n\tif ((x != NULL) && (*x == NULL))\n\t\t*x=sk;\n\treturn(sk);\nerr:\n\tX509err(X509_F_X509V3_ADD_EXT,ERR_R_MALLOC_FAILURE);\nerr2:\n\tif (new_ex != NULL) X509_EXTENSION_free(new_ex);\n\tif (sk != NULL) sk_free(sk);\n\treturn(NULL);\n\t}', 'STACK *sk_new(int (*c)())\n\t{\n\tSTACK *ret;\n\tint i;\n\tif ((ret=(STACK *)Malloc(sizeof(STACK))) == NULL)\n\t\tgoto err0;\n\tif ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)\n\t\tgoto err1;\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);\nerr1:\n\tFree((char *)ret);\nerr0:\n\treturn(NULL);\n\t}', 'X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex)\n\t{\n\treturn((X509_EXTENSION *)ASN1_dup(\n\t\t(int (*)())i2d_X509_EXTENSION,\n\t\t(char *(*)())d2i_X509_EXTENSION,(char *)ex));\n\t}', 'char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x)\n\t{\n\tunsigned char *b,*p;\n\tlong i;\n\tchar *ret;\n\tif (x == NULL) return(NULL);\n\ti=(long)i2d(x,NULL);\n\tb=(unsigned char *)Malloc((unsigned int)i+10);\n\tif (b == NULL)\n\t\t{ ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }\n\tp= b;\n\ti=i2d(x,&p);\n\tp= b;\n\tret=d2i(NULL,&p,i);\n\tFree((char *)b);\n\treturn(ret);\n\t}']