crypto/x509/x509_lu.c:536: error: NULL_DEREFERENCE
  pointer `obj` last assigned on line 535 could be null and is dereferenced at line 536, column 7.
Showing all 25 steps of the trace


crypto/x509/x509_lu.c:502:1: start of procedure X509_STORE_get1_certs()
500.   	}
501.   
502. > STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
503.   	{
504.   	int i, idx, cnt;

crypto/x509/x509_lu.c:508:2: 
506.   	X509 *x;
507.   	X509_OBJECT *obj;
508. > 	sk = sk_X509_new_null();
509.   	CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
510.   	idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);

crypto/stack/stack.c:153:1: start of procedure sk_new_null()
  151.   	}
  152.   
  153. > _STACK *sk_new_null(void)
  154.   	{
  155.   	return sk_new((int (*)(const void *, const void *))0);

crypto/stack/stack.c:155:2: Skipping sk_new(): empty list of specs
  153.   _STACK *sk_new_null(void)
  154.   	{
  155.   	return sk_new((int (*)(const void *, const void *))0);
          ^
  156.   	}
  157.   

crypto/stack/stack.c:156:2: return from a call to sk_new_null
  154.   	{
  155.   	return sk_new((int (*)(const void *, const void *))0);
  156.   	}
          ^
  157.   
  158.   _STACK *sk_new(int (*c)(const void *, const void *))

crypto/x509/x509_lu.c:509:2: 
507.   	X509_OBJECT *obj;
508.   	sk = sk_X509_new_null();
509. > 	CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
510.   	idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
511.   	if (idx < 0)

crypto/lock.c:423:1: start of procedure CRYPTO_lock()
  421.   	}
  422.   
  423. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  424.   	{
  425.   #ifdef LOCK_DEBUG

crypto/lock.c:450:6: Taking false branch
  448.   		}
  449.   #endif
  450.   	if (type < 0)
              ^
  451.   		{
  452.   		if (dynlock_lock_callback != NULL)

crypto/lock.c:465:7: Taking true branch
  463.   		}
  464.   	else
  465.   		if (locking_callback != NULL)
               ^
  466.   			locking_callback(mode,type,file,line);
  467.   	}

crypto/lock.c:466:4: Skipping __function_pointer__(): unresolved function pointer
  464.   	else
  465.   		if (locking_callback != NULL)
  466.   			locking_callback(mode,type,file,line);
            ^
  467.   	}
  468.   

crypto/lock.c:450:2: 
  448.   		}
  449.   #endif
  450. > 	if (type < 0)
  451.   		{
  452.   		if (dynlock_lock_callback != NULL)

crypto/lock.c:467:2: return from a call to CRYPTO_lock
  465.   		if (locking_callback != NULL)
  466.   			locking_callback(mode,type,file,line);
  467.   	}
          ^
  468.   
  469.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/x509/x509_lu.c:510:2: Skipping x509_object_idx_cnt(): empty list of specs
508.   	sk = sk_X509_new_null();
509.   	CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
510.   	idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
        ^
511.   	if (idx < 0)
512.   		{

crypto/x509/x509_lu.c:511:6: Taking false branch
509.   	CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
510.   	idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
511.   	if (idx < 0)
            ^
512.   		{
513.   		/* Nothing found in cache: do lookup to possibly add new

crypto/x509/x509_lu.c:533:7: 
531.   			}
532.   		}
533. > 	for (i = 0; i < cnt; i++, idx++)
534.   		{
535.   		obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);

crypto/x509/x509_lu.c:533:14: Loop condition is true. Entering loop body
531.   			}
532.   		}
533.   	for (i = 0; i < cnt; i++, idx++)
                    ^
534.   		{
535.   		obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);

crypto/x509/x509_lu.c:535:9: Condition is true
533.   	for (i = 0; i < cnt; i++, idx++)
534.   		{
535.   		obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
               ^
536.   		x = obj->data.x509;
537.   		CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);

crypto/x509/x509_lu.c:535:3: 
533.   	for (i = 0; i < cnt; i++, idx++)
534.   		{
535. > 		obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
536.   		x = obj->data.x509;
537.   		CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);

crypto/stack/stack.c:338:1: start of procedure sk_value()
  336.   }
  337.   
  338. > void *sk_value(const _STACK *st, int i)
  339.   {
  340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:340:6: Taking false branch
  338.   void *sk_value(const _STACK *st, int i)
  339.   {
  340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  341.   	return st->data[i];
  342.   }

crypto/stack/stack.c:340:13: Taking false branch
  338.   void *sk_value(const _STACK *st, int i)
  339.   {
  340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  341.   	return st->data[i];
  342.   }

crypto/stack/stack.c:340:24: Taking true branch
  338.   void *sk_value(const _STACK *st, int i)
  339.   {
  340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                                ^
  341.   	return st->data[i];
  342.   }

crypto/stack/stack.c:340:39: 
  338.   void *sk_value(const _STACK *st, int i)
  339.   {
  340. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
  341.   	return st->data[i];
  342.   }

crypto/stack/stack.c:342:1: return from a call to sk_value
  340.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  341.   	return st->data[i];
  342. > }
  343.   
  344.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_lu.c:536:3: 
534.   		{
535.   		obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
536. > 		x = obj->data.x509;
537.   		CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
538.   		if (!sk_X509_push(sk, x))

STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
	{
	int i, idx, cnt;
	STACK_OF(X509) *sk;
	X509 *x;
	X509_OBJECT *obj;
	sk = sk_X509_new_null();
	CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
	idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
	if (idx < 0)
		{
		X509_OBJECT xobj;
		CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
		if (!X509_STORE_get_by_subject(ctx, X509_LU_X509, nm, &xobj))
			{
			sk_X509_free(sk);
			return NULL;
			}
		X509_OBJECT_free_contents(&xobj);
		CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
		idx = x509_object_idx_cnt(ctx->ctx->objs,X509_LU_X509,nm, &cnt);
		if (idx < 0)
			{
			CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
			sk_X509_free(sk);
			return NULL;
			}
		}
	for (i = 0; i < cnt; i++, idx++)
		{
		obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
		x = obj->data.x509;
		CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
		if (!sk_X509_push(sk, x))
			{
			CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
			X509_free(x);
			sk_X509_pop_free(sk, X509_free);
			return NULL;
			}
		}
	CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
	return sk;
	}
['STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)\n\t{\n\tint i, idx, cnt;\n\tSTACK_OF(X509) *sk;\n\tX509 *x;\n\tX509_OBJECT *obj;\n\tsk = sk_X509_new_null();\n\tCRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);\n\tidx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);\n\tif (idx < 0)\n\t\t{\n\t\tX509_OBJECT xobj;\n\t\tCRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);\n\t\tif (!X509_STORE_get_by_subject(ctx, X509_LU_X509, nm, &xobj))\n\t\t\t{\n\t\t\tsk_X509_free(sk);\n\t\t\treturn NULL;\n\t\t\t}\n\t\tX509_OBJECT_free_contents(&xobj);\n\t\tCRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);\n\t\tidx = x509_object_idx_cnt(ctx->ctx->objs,X509_LU_X509,nm, &cnt);\n\t\tif (idx < 0)\n\t\t\t{\n\t\t\tCRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);\n\t\t\tsk_X509_free(sk);\n\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\tfor (i = 0; i < cnt; i++, idx++)\n\t\t{\n\t\tobj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);\n\t\tx = obj->data.x509;\n\t\tCRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);\n\t\tif (!sk_X509_push(sk, x))\n\t\t\t{\n\t\t\tCRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);\n\t\t\tX509_free(x);\n\t\t\tsk_X509_pop_free(sk, X509_free);\n\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\tCRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);\n\treturn sk;\n\t}', '_STACK *sk_new_null(void)\n\t{\n\treturn sk_new((int (*)(const void *, const void *))0);\n\t}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n\t{\n#ifdef LOCK_DEBUG\n\t\t{\n\t\tCRYPTO_THREADID id;\n\t\tchar *rw_text,*operation_text;\n\t\tif (mode & CRYPTO_LOCK)\n\t\t\toperation_text="lock  ";\n\t\telse if (mode & CRYPTO_UNLOCK)\n\t\t\toperation_text="unlock";\n\t\telse\n\t\t\toperation_text="ERROR ";\n\t\tif (mode & CRYPTO_READ)\n\t\t\trw_text="r";\n\t\telse if (mode & CRYPTO_WRITE)\n\t\t\trw_text="w";\n\t\telse\n\t\t\trw_text="ERROR";\n\t\tCRYPTO_THREADID_current(&id);\n\t\tfprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\\n",\n\t\t\tCRYPTO_THREADID_hash(&id), rw_text, operation_text,\n\t\t\tCRYPTO_get_lock_name(type), file, line);\n\t\t}\n#endif\n\tif (type < 0)\n\t\t{\n\t\tif (dynlock_lock_callback != NULL)\n\t\t\t{\n\t\t\tstruct CRYPTO_dynlock_value *pointer\n\t\t\t\t= CRYPTO_get_dynlock_value(type);\n\t\t\tOPENSSL_assert(pointer != NULL);\n\t\t\tdynlock_lock_callback(mode, pointer, file, line);\n\t\t\tCRYPTO_destroy_dynlockid(type);\n\t\t\t}\n\t\t}\n\telse\n\t\tif (locking_callback != NULL)\n\t\t\tlocking_callback(mode,type,file,line);\n\t}', 'void *sk_value(const _STACK *st, int i)\n{\n\tif(!st || (i < 0) || (i >= st->num)) return NULL;\n\treturn st->data[i];\n}']