crypto/engine/engine_list.c:207: error: NULL_DEREFERENCE
  pointer `def_engine` last assigned on line 198 could be null and is dereferenced at line 207, column 2.
Showing all 50 steps of the trace


crypto/engine/engine_list.c:190:1: start of procedure engine_internal_check()
188.    * don't output errors for failures of the engine_list_add function
189.    * as it will generate errors itself. */
190. > static int engine_internal_check(void)
191.   	{
192.   	int toret = 1;

crypto/engine/engine_list.c:192:2: 
190.   static int engine_internal_check(void)
191.   	{
192. > 	int toret = 1;
193.   	ENGINE *def_engine;
194.   	if(engine_list_flag)

crypto/engine/engine_list.c:194:5: Taking false branch
192.   	int toret = 1;
193.   	ENGINE *def_engine;
194.   	if(engine_list_flag)
           ^
195.   		return 1;
196.   	/* This is our first time up, we need to populate the list

crypto/engine/engine_list.c:198:2: 
196.   	/* This is our first time up, we need to populate the list
197.   	 * with our statically compiled-in engines. */
198. > 	def_engine = ENGINE_openssl();
199.   	if(!engine_list_add(def_engine))
200.   		toret = 0;

crypto/engine/engine_openssl.c:79:1: start of procedure ENGINE_openssl()
  77.   /* As this is only ever called once, there's no need for locking
  78.    * (indeed - the lock will already be held by our caller!!!) */
  79. > ENGINE *ENGINE_openssl()
  80.   	{
  81.   	ENGINE *ret = ENGINE_new();

crypto/engine/engine_openssl.c:81:2: Skipping ENGINE_new(): empty list of specs
  79.   ENGINE *ENGINE_openssl()
  80.   	{
  81.   	ENGINE *ret = ENGINE_new();
         ^
  82.   	if(!ret)
  83.   		return NULL;

crypto/engine/engine_openssl.c:82:6: Taking false branch
  80.   	{
  81.   	ENGINE *ret = ENGINE_new();
  82.   	if(!ret)
             ^
  83.   		return NULL;
  84.   	if(!ENGINE_set_id(ret, engine_openssl_id) ||

crypto/engine/engine_openssl.c:84:6: 
  82.   	if(!ret)
  83.   		return NULL;
  84. > 	if(!ENGINE_set_id(ret, engine_openssl_id) ||
  85.   			!ENGINE_set_name(ret, engine_openssl_name) ||
  86.   #ifndef OPENSSL_NO_RSA

crypto/engine/engine_list.c:468:1: start of procedure ENGINE_set_id()
    466.   	}
    467.   
    468. > int ENGINE_set_id(ENGINE *e, const char *id)
    469.   	{
    470.   	if(id == NULL)

crypto/engine/engine_list.c:470:5: Taking false branch
    468.   int ENGINE_set_id(ENGINE *e, const char *id)
    469.   	{
    470.   	if(id == NULL)
               ^
    471.   		{
    472.   		ENGINEerr(ENGINE_F_ENGINE_SET_ID,

crypto/engine/engine_list.c:476:2: 
    474.   		return 0;
    475.   		}
    476. > 	e->id = id;
    477.   	return 1;
    478.   	}

crypto/engine/engine_list.c:477:2: 
    475.   		}
    476.   	e->id = id;
    477. > 	return 1;
    478.   	}
    479.   

crypto/engine/engine_list.c:478:2: return from a call to ENGINE_set_id
    476.   	e->id = id;
    477.   	return 1;
    478.   	}
            ^
    479.   
    480.   int ENGINE_set_name(ENGINE *e, const char *name)

crypto/engine/engine_openssl.c:84:6: Taking false branch
  82.   	if(!ret)
  83.   		return NULL;
  84.   	if(!ENGINE_set_id(ret, engine_openssl_id) ||
             ^
  85.   			!ENGINE_set_name(ret, engine_openssl_name) ||
  86.   #ifndef OPENSSL_NO_RSA

crypto/engine/engine_openssl.c:85:5: 
  83.   		return NULL;
  84.   	if(!ENGINE_set_id(ret, engine_openssl_id) ||
  85. > 			!ENGINE_set_name(ret, engine_openssl_name) ||
  86.   #ifndef OPENSSL_NO_RSA
  87.   			!ENGINE_set_RSA(ret, RSA_get_default_openssl_method()) ||

crypto/engine/engine_list.c:480:1: start of procedure ENGINE_set_name()
    478.   	}
    479.   
    480. > int ENGINE_set_name(ENGINE *e, const char *name)
    481.   	{
    482.   	if(name == NULL)

crypto/engine/engine_list.c:482:5: Taking true branch
    480.   int ENGINE_set_name(ENGINE *e, const char *name)
    481.   	{
    482.   	if(name == NULL)
               ^
    483.   		{
    484.   		ENGINEerr(ENGINE_F_ENGINE_SET_NAME,

crypto/engine/engine_list.c:484:3: 
    482.   	if(name == NULL)
    483.   		{
    484. > 		ENGINEerr(ENGINE_F_ENGINE_SET_NAME,
    485.   			ERR_R_PASSED_NULL_PARAMETER);
    486.   		return 0;

crypto/err/err.c:357:1: start of procedure ERR_put_error()
      355.   /********************************************************/
      356.   
      357. > void ERR_put_error(int lib, int func, int reason, const char *file,
      358.   	     int line)
      359.   	{

crypto/err/err.c:381:2: Skipping ERR_get_state(): empty list of specs
      379.   	}
      380.   #endif
      381.   	es=ERR_get_state();
              ^
      382.   
      383.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:383:2: 
      381.   	es=ERR_get_state();
      382.   
      383. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
      384.   	if (es->top == es->bottom)
      385.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:384:6: Taking false branch
      382.   
      383.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
      384.   	if (es->top == es->bottom)
                  ^
      385.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      386.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);

crypto/err/err.c:386:2: 
      384.   	if (es->top == es->bottom)
      385.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      386. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      387.   	es->err_file[es->top]=file;
      388.   	es->err_line[es->top]=line;

crypto/err/err.c:387:2: 
      385.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      386.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      387. > 	es->err_file[es->top]=file;
      388.   	es->err_line[es->top]=line;
      389.   	err_clear_data(es,es->top);

crypto/err/err.c:388:2: 
      386.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      387.   	es->err_file[es->top]=file;
      388. > 	es->err_line[es->top]=line;
      389.   	err_clear_data(es,es->top);
      390.   	}

crypto/err/err.c:389:2: Taking true branch
      387.   	es->err_file[es->top]=file;
      388.   	es->err_line[es->top]=line;
      389.   	err_clear_data(es,es->top);
              ^
      390.   	}
      391.   

crypto/err/err.c:389:2: Taking false branch
      387.   	es->err_file[es->top]=file;
      388.   	es->err_line[es->top]=line;
      389.   	err_clear_data(es,es->top);
              ^
      390.   	}
      391.   

crypto/err/err.c:390:2: return from a call to ERR_put_error
      388.   	es->err_line[es->top]=line;
      389.   	err_clear_data(es,es->top);
      390.   	}
              ^
      391.   
      392.   void ERR_clear_error(void)

crypto/engine/engine_list.c:486:3: 
    484.   		ENGINEerr(ENGINE_F_ENGINE_SET_NAME,
    485.   			ERR_R_PASSED_NULL_PARAMETER);
    486. > 		return 0;
    487.   		}
    488.   	e->name = name;

crypto/engine/engine_list.c:490:2: return from a call to ENGINE_set_name
    488.   	e->name = name;
    489.   	return 1;
    490.   	}
            ^
    491.   
    492.   int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth)

crypto/engine/engine_openssl.c:85:5: Taking true branch
  83.   		return NULL;
  84.   	if(!ENGINE_set_id(ret, engine_openssl_id) ||
  85.   			!ENGINE_set_name(ret, engine_openssl_name) ||
            ^
  86.   #ifndef OPENSSL_NO_RSA
  87.   			!ENGINE_set_RSA(ret, RSA_get_default_openssl_method()) ||

crypto/engine/engine_openssl.c:99:3: 
  97.   			!ENGINE_set_BN_mod_exp_crt(ret, openssl_mod_exp_crt))
  98.   		{
  99. > 		ENGINE_free(ret);
  100.   		return NULL;
  101.   		}

crypto/engine/engine_list.c:407:1: start of procedure ENGINE_free()
    405.   	}
    406.   
    407. > int ENGINE_free(ENGINE *e)
    408.   	{
    409.   	int i;

crypto/engine/engine_list.c:411:5: Taking false branch
    409.   	int i;
    410.   
    411.   	if(e == NULL)
               ^
    412.   		{
    413.   		ENGINEerr(ENGINE_F_ENGINE_FREE,

crypto/engine/engine_list.c:417:2: 
    415.   		return 0;
    416.   		}
    417. > 	i = CRYPTO_add(&e->struct_ref,-1,CRYPTO_LOCK_ENGINE);
    418.   	engine_ref_debug(e, 0, -1)
    419.   	if (i > 0) return 1;

crypto/cryptlib.c:415:1: start of procedure CRYPTO_add_lock()
      413.   	}
      414.   
      415. > int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
      416.   	     int line)
      417.   	{

crypto/cryptlib.c:418:2: 
      416.   	     int line)
      417.   	{
      418. > 	int ret = 0;
      419.   
      420.   	if (add_lock_callback != NULL)

crypto/cryptlib.c:420:6: Taking true branch
      418.   	int ret = 0;
      419.   
      420.   	if (add_lock_callback != NULL)
                  ^
      421.   		{
      422.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:426:3: Skipping __function_pointer__(): unresolved function pointer
      424.   #endif
      425.   
      426.   		ret=add_lock_callback(pointer,amount,type,file,line);
               ^
      427.   #ifdef LOCK_DEBUG
      428.   		fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",

crypto/cryptlib.c:434:3: 
      432.   			file,line);
      433.   #endif
      434. > 		*pointer=ret;
      435.   		}
      436.   	else

crypto/cryptlib.c:451:2: 
      449.   		CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line);
      450.   		}
      451. > 	return(ret);
      452.   	}
      453.   

crypto/cryptlib.c:452:2: return from a call to CRYPTO_add_lock
      450.   		}
      451.   	return(ret);
      452.   	}
              ^
      453.   
      454.   const char *CRYPTO_get_lock_name(int type)

crypto/engine/engine_list.c:419:6: Taking true branch
    417.   	i = CRYPTO_add(&e->struct_ref,-1,CRYPTO_LOCK_ENGINE);
    418.   	engine_ref_debug(e, 0, -1)
    419.   	if (i > 0) return 1;
                ^
    420.   #ifdef REF_CHECK
    421.   	if (i < 0)

crypto/engine/engine_list.c:419:13: 
    417.   	i = CRYPTO_add(&e->struct_ref,-1,CRYPTO_LOCK_ENGINE);
    418.   	engine_ref_debug(e, 0, -1)
    419. > 	if (i > 0) return 1;
    420.   #ifdef REF_CHECK
    421.   	if (i < 0)

crypto/engine/engine_list.c:430:2: return from a call to ENGINE_free
    428.   	OPENSSL_free(e);
    429.   	return 1;
    430.   	}
            ^
    431.   
    432.   int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,

crypto/engine/engine_openssl.c:100:3: 
  98.   		{
  99.   		ENGINE_free(ret);
  100. > 		return NULL;
  101.   		}
  102.   	return ret;

crypto/engine/engine_openssl.c:103:2: return from a call to ENGINE_openssl
  101.   		}
  102.   	return ret;
  103.   	}
          ^
  104.   
  105.   /* Chinese Remainder Theorem, taken and adapted from rsa_eay.c */

crypto/engine/engine_list.c:199:6: Taking true branch
197.   	 * with our statically compiled-in engines. */
198.   	def_engine = ENGINE_openssl();
199.   	if(!engine_list_add(def_engine))
            ^
200.   		toret = 0;
201.   	else

crypto/engine/engine_list.c:200:3: 
198.   	def_engine = ENGINE_openssl();
199.   	if(!engine_list_add(def_engine))
200. > 		toret = 0;
201.   	else
202.   		engine_list_flag = 1;

crypto/engine/engine_list.c:207:2: 
205.   #else
206.   	/* We can't ENGINE_free() because the lock's already held */
207. > 	def_engine->struct_ref--;
208.   	engine_ref_debug(def_engine, 0, -1)
209.   #endif

static int engine_internal_check(void)
	{
	int toret = 1;
	ENGINE *def_engine;
	if(engine_list_flag)
		return 1;
	def_engine = ENGINE_openssl();
	if(!engine_list_add(def_engine))
		toret = 0;
	else
		engine_list_flag = 1;
#if 0
	ENGINE_free(def_engine);
#else
	def_engine->struct_ref--;
	engine_ref_debug(def_engine, 0, -1)
#endif
	return 1;
	}
['static int engine_internal_check(void)\n\t{\n\tint toret = 1;\n\tENGINE *def_engine;\n\tif(engine_list_flag)\n\t\treturn 1;\n\tdef_engine = ENGINE_openssl();\n\tif(!engine_list_add(def_engine))\n\t\ttoret = 0;\n\telse\n\t\tengine_list_flag = 1;\n#if 0\n\tENGINE_free(def_engine);\n#else\n\tdef_engine->struct_ref--;\n\tengine_ref_debug(def_engine, 0, -1)\n#endif\n\treturn 1;\n\t}', 'ENGINE *ENGINE_openssl()\n\t{\n\tENGINE *ret = ENGINE_new();\n\tif(!ret)\n\t\treturn NULL;\n\tif(!ENGINE_set_id(ret, engine_openssl_id) ||\n\t\t\t!ENGINE_set_name(ret, engine_openssl_name) ||\n#ifndef OPENSSL_NO_RSA\n\t\t\t!ENGINE_set_RSA(ret, RSA_get_default_openssl_method()) ||\n#endif\n#ifndef OPENSSL_NO_DSA\n\t\t\t!ENGINE_set_DSA(ret, DSA_get_default_openssl_method()) ||\n#endif\n#ifndef OPENSSL_NO_DH\n\t\t\t!ENGINE_set_DH(ret, DH_get_default_openssl_method()) ||\n#endif\n\t\t\t!ENGINE_set_RAND(ret, RAND_SSLeay()) ||\n\t\t\t!ENGINE_set_BN_mod_exp(ret, BN_mod_exp) ||\n\t\t\t!ENGINE_set_BN_mod_exp_crt(ret, openssl_mod_exp_crt))\n\t\t{\n\t\tENGINE_free(ret);\n\t\treturn NULL;\n\t\t}\n\treturn ret;\n\t}', 'int ENGINE_set_id(ENGINE *e, const char *id)\n\t{\n\tif(id == NULL)\n\t\t{\n\t\tENGINEerr(ENGINE_F_ENGINE_SET_ID,\n\t\t\tERR_R_PASSED_NULL_PARAMETER);\n\t\treturn 0;\n\t\t}\n\te->id = id;\n\treturn 1;\n\t}', 'int ENGINE_set_name(ENGINE *e, const char *name)\n\t{\n\tif(name == NULL)\n\t\t{\n\t\tENGINEerr(ENGINE_F_ENGINE_SET_NAME,\n\t\t\tERR_R_PASSED_NULL_PARAMETER);\n\t\treturn 0;\n\t\t}\n\te->name = name;\n\treturn 1;\n\t}', 'void ERR_put_error(int lib, int func, int reason, const char *file,\n\t     int line)\n\t{\n\tERR_STATE *es;\n#ifdef _OSD_POSIX\n\tif (strncmp(file,"*POSIX(", sizeof("*POSIX(")-1) == 0) {\n\t\tchar *end;\n\t\tfile += sizeof("*POSIX(")-1;\n\t\tend = &file[strlen(file)-1];\n\t\tif (*end == \')\')\n\t\t\t*end = \'\\0\';\n\t\tif ((end = strrchr(file, \'/\')) != NULL)\n\t\t\tfile = &end[1];\n\t}\n#endif\n\tes=ERR_get_state();\n\tes->top=(es->top+1)%ERR_NUM_ERRORS;\n\tif (es->top == es->bottom)\n\t\tes->bottom=(es->bottom+1)%ERR_NUM_ERRORS;\n\tes->err_buffer[es->top]=ERR_PACK(lib,func,reason);\n\tes->err_file[es->top]=file;\n\tes->err_line[es->top]=line;\n\terr_clear_data(es,es->top);\n\t}', 'int ENGINE_free(ENGINE *e)\n\t{\n\tint i;\n\tif(e == NULL)\n\t\t{\n\t\tENGINEerr(ENGINE_F_ENGINE_FREE,\n\t\t\tERR_R_PASSED_NULL_PARAMETER);\n\t\treturn 0;\n\t\t}\n\ti = CRYPTO_add(&e->struct_ref,-1,CRYPTO_LOCK_ENGINE);\n\tengine_ref_debug(e, 0, -1)\n\tif (i > 0) return 1;\n#ifdef REF_CHECK\n\tif (i < 0)\n\t\t{\n\t\tfprintf(stderr,"ENGINE_free, bad structural reference count\\n");\n\t\tabort();\n\t\t}\n#endif\n\tCRYPTO_free_ex_data(engine_ex_data_stack, e, &e->ex_data);\n\tOPENSSL_free(e);\n\treturn 1;\n\t}', 'int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,\n\t     int line)\n\t{\n\tint ret = 0;\n\tif (add_lock_callback != NULL)\n\t\t{\n#ifdef LOCK_DEBUG\n\t\tint before= *pointer;\n#endif\n\t\tret=add_lock_callback(pointer,amount,type,file,line);\n#ifdef LOCK_DEBUG\n\t\tfprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\\n",\n\t\t\tCRYPTO_thread_id(),\n\t\t\tbefore,amount,ret,\n\t\t\tCRYPTO_get_lock_name(type),\n\t\t\tfile,line);\n#endif\n\t\t*pointer=ret;\n\t\t}\n\telse\n\t\t{\n\t\tCRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,file,line);\n\t\tret= *pointer+amount;\n#ifdef LOCK_DEBUG\n\t\tfprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\\n",\n\t\t\tCRYPTO_thread_id(),\n\t\t\t*pointer,amount,ret,\n\t\t\tCRYPTO_get_lock_name(type),\n\t\t\tfile,line);\n#endif\n\t\t*pointer=ret;\n\t\tCRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line);\n\t\t}\n\treturn(ret);\n\t}']