ssl/ssl_lib.c:1235: error: NULL_DEREFERENCE
  pointer `sk` last assigned on line 1222 could be null and is dereferenced by call to `sk_push()` at line 1235, column 9.
Showing all 33 steps of the trace


ssl/ssl_lib.c:1208:1: start of procedure ssl_bytes_to_cipher_list()
1206.   	}
1207.   
1208. > STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,
1209.   					       STACK_OF(SSL_CIPHER) **skp)
1210.   	{

ssl/ssl_lib.c:1215:2: Skipping __function_pointer__(): unresolved function pointer
1213.   	int i,n;
1214.   
1215.   	n=ssl_put_cipher_by_char(s,NULL,NULL);
         ^
1216.   	if ((num%n) != 0)
1217.   		{

ssl/ssl_lib.c:1216:6: Taking false branch
1214.   
1215.   	n=ssl_put_cipher_by_char(s,NULL,NULL);
1216.   	if ((num%n) != 0)
             ^
1217.   		{
1218.   		SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);

ssl/ssl_lib.c:1221:7: Taking false branch
1219.   		return(NULL);
1220.   		}
1221.   	if ((skp == NULL) || (*skp == NULL))
              ^
1222.   		sk=sk_SSL_CIPHER_new_null(); /* change perhaps later */
1223.   	else

ssl/ssl_lib.c:1221:24: Taking true branch
1219.   		return(NULL);
1220.   		}
1221.   	if ((skp == NULL) || (*skp == NULL))
                               ^
1222.   		sk=sk_SSL_CIPHER_new_null(); /* change perhaps later */
1223.   	else

ssl/ssl_lib.c:1222:3: 
1220.   		}
1221.   	if ((skp == NULL) || (*skp == NULL))
1222. > 		sk=sk_SSL_CIPHER_new_null(); /* change perhaps later */
1223.   	else
1224.   		{

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

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

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

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

crypto/mem.c:289:1: start of procedure CRYPTO_malloc()
      287.   	}
      288.   
      289. > void *CRYPTO_malloc(int num, const char *file, int line)
      290.   	{
      291.   	void *ret = NULL;

crypto/mem.c:291:2: 
      289.   void *CRYPTO_malloc(int num, const char *file, int line)
      290.   	{
      291. > 	void *ret = NULL;
      292.   	extern unsigned char cleanse_ctr;
      293.   

crypto/mem.c:294:2: 
      292.   	extern unsigned char cleanse_ctr;
      293.   
      294. > 	allow_customize = 0;
      295.   	if (malloc_debug_func != NULL)
      296.   		{

crypto/mem.c:295:6: Taking false branch
      293.   
      294.   	allow_customize = 0;
      295.   	if (malloc_debug_func != NULL)
                  ^
      296.   		{
      297.   		allow_customize_debug = 0;

crypto/mem.c:300:2: Skipping __function_pointer__(): unresolved function pointer
      298.   		malloc_debug_func(NULL, num, file, line, 0);
      299.   		}
      300.   	ret = malloc_ex_func(num,file,line);
              ^
      301.   #ifdef LEVITTE_DEBUG_MEM
      302.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);

crypto/mem.c:304:6: Taking false branch
      302.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
      303.   #endif
      304.   	if (malloc_debug_func != NULL)
                  ^
      305.   		malloc_debug_func(ret, num, file, line, 1);
      306.   

crypto/mem.c:310:12: Taking false branch
      308.            * sanitisation function can't be optimised out. NB: We only do
      309.            * this for >2Kb so the overhead doesn't bother us. */
      310.           if(ret && (num > 2048))
                        ^
      311.                   ((unsigned char *)ret)[0] = cleanse_ctr;
      312.   

crypto/mem.c:313:2: 
      311.                   ((unsigned char *)ret)[0] = cleanse_ctr;
      312.   
      313. > 	return ret;
      314.   	}
      315.   

crypto/mem.c:314:2: return from a call to CRYPTO_malloc
      312.   
      313.   	return ret;
      314.   	}
              ^
      315.   
      316.   void *CRYPTO_realloc(void *str, int num, const char *file, int line)

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

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

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

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

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

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

ssl/ssl_lib.c:1229:7: 
1227.   		}
1228.   
1229. > 	for (i=0; i<num; i+=n)
1230.   		{
1231.   		c=ssl_get_cipher_by_char(s,p);

ssl/ssl_lib.c:1229:12: Loop condition is true. Entering loop body
1227.   		}
1228.   
1229.   	for (i=0; i<num; i+=n)
                   ^
1230.   		{
1231.   		c=ssl_get_cipher_by_char(s,p);

ssl/ssl_lib.c:1231:3: Skipping __function_pointer__(): unresolved function pointer
1229.   	for (i=0; i<num; i+=n)
1230.   		{
1231.   		c=ssl_get_cipher_by_char(s,p);
          ^
1232.   		p+=n;
1233.   		if (c != NULL)

ssl/ssl_lib.c:1232:3: 
1230.   		{
1231.   		c=ssl_get_cipher_by_char(s,p);
1232. > 		p+=n;
1233.   		if (c != NULL)
1234.   			{

ssl/ssl_lib.c:1233:7: Taking true branch
1231.   		c=ssl_get_cipher_by_char(s,p);
1232.   		p+=n;
1233.   		if (c != NULL)
              ^
1234.   			{
1235.   			if (!sk_SSL_CIPHER_push(sk,c))

ssl/ssl_lib.c:1235:9: 
1233.   		if (c != NULL)
1234.   			{
1235. > 			if (!sk_SSL_CIPHER_push(sk,c))
1236.   				{
1237.   				SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,ERR_R_MALLOC_FAILURE);

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.   

STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,
					       STACK_OF(SSL_CIPHER) **skp)
	{
	SSL_CIPHER *c;
	STACK_OF(SSL_CIPHER) *sk;
	int i,n;
	n=ssl_put_cipher_by_char(s,NULL,NULL);
	if ((num%n) != 0)
		{
		SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);
		return(NULL);
		}
	if ((skp == NULL) || (*skp == NULL))
		sk=sk_SSL_CIPHER_new_null();
	else
		{
		sk= *skp;
		sk_SSL_CIPHER_zero(sk);
		}
	for (i=0; i<num; i+=n)
		{
		c=ssl_get_cipher_by_char(s,p);
		p+=n;
		if (c != NULL)
			{
			if (!sk_SSL_CIPHER_push(sk,c))
				{
				SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,ERR_R_MALLOC_FAILURE);
				goto err;
				}
			}
		}
	if (skp != NULL)
		*skp=sk;
	return(sk);
err:
	if ((skp == NULL) || (*skp == NULL))
		sk_SSL_CIPHER_free(sk);
	return(NULL);
	}
['STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,\n\t\t\t\t\t       STACK_OF(SSL_CIPHER) **skp)\n\t{\n\tSSL_CIPHER *c;\n\tSTACK_OF(SSL_CIPHER) *sk;\n\tint i,n;\n\tn=ssl_put_cipher_by_char(s,NULL,NULL);\n\tif ((num%n) != 0)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);\n\t\treturn(NULL);\n\t\t}\n\tif ((skp == NULL) || (*skp == NULL))\n\t\tsk=sk_SSL_CIPHER_new_null();\n\telse\n\t\t{\n\t\tsk= *skp;\n\t\tsk_SSL_CIPHER_zero(sk);\n\t\t}\n\tfor (i=0; i<num; i+=n)\n\t\t{\n\t\tc=ssl_get_cipher_by_char(s,p);\n\t\tp+=n;\n\t\tif (c != NULL)\n\t\t\t{\n\t\t\tif (!sk_SSL_CIPHER_push(sk,c))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,ERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (skp != NULL)\n\t\t*skp=sk;\n\treturn(sk);\nerr:\n\tif ((skp == NULL) || (*skp == NULL))\n\t\tsk_SSL_CIPHER_free(sk);\n\treturn(NULL);\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\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}', 'int sk_push(STACK *st, char *data)\n\t{\n\treturn(sk_insert(st,data,st->num));\n\t}']