crypto/mem_dbg.c:698: error: NULL_DEREFERENCE
  pointer `lcl` last assigned on line 695 could be null and is dereferenced at line 698, column 4.
Showing all 7 steps of the trace


crypto/mem_dbg.c:678:1: start of procedure print_leak_doall_arg()
676.   	} MEM_LEAK;
677.   
678. > static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
679.   	{
680.   	char buf[1024];

crypto/mem_dbg.c:681:2: 
679.   	{
680.   	char buf[1024];
681. > 	char *bufp = buf;
682.   	APP_INFO *amip;
683.   	int ami_cnt;

crypto/mem_dbg.c:684:2: 
682.   	APP_INFO *amip;
683.   	int ami_cnt;
684. > 	struct tm *lcl = NULL;
685.   	unsigned long ti;
686.   	void *tip;

crypto/mem_dbg.c:690:5: Taking false branch
688.   #define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
689.   
690.   	if(m->addr == (char *)l->bio)
           ^
691.   	    return;
692.   

crypto/mem_dbg.c:693:6: Taking true branch
691.   	    return;
692.   
693.   	if (options & V_CRYPTO_MDEBUG_TIME)
            ^
694.   		{
695.   		lcl = localtime(&m->time);

crypto/mem_dbg.c:695:3: 
693.   	if (options & V_CRYPTO_MDEBUG_TIME)
694.   		{
695. > 		lcl = localtime(&m->time);
696.   	
697.   		BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",

crypto/mem_dbg.c:697:3: 
695.   		lcl = localtime(&m->time);
696.   	
697. > 		BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
698.   			lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
699.   		bufp += strlen(bufp);

static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
	{
	char buf[1024];
	char *bufp = buf;
	APP_INFO *amip;
	int ami_cnt;
	struct tm *lcl = NULL;
	unsigned long ti;
	void *tip;
#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
	if(m->addr == (char *)l->bio)
	    return;
	if (options & V_CRYPTO_MDEBUG_TIME)
		{
		lcl = localtime(&m->time);
		BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
			lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
		bufp += strlen(bufp);
		}
	BIO_snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",
		m->order,m->file,m->line);
	bufp += strlen(bufp);
	if (options & V_CRYPTO_MDEBUG_THREAD)
		{
		BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu/%p, ", m->thread_id, m->thread_idptr);
		bufp += strlen(bufp);
		}
	BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\n",
		m->num,(unsigned long)m->addr);
	bufp += strlen(bufp);
	BIO_puts(l->bio,buf);
	l->chunks++;
	l->bytes+=m->num;
	amip=m->app_info;
	ami_cnt=0;
	if (!amip)
		return;
	ti=amip->thread_id;
	tip=amip->thread_idptr;
	do
		{
		int buf_len;
		int info_len;
		ami_cnt++;
		memset(buf,'>',ami_cnt);
		BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
			" thread=%lu/%p, file=%s, line=%d, info=\"",
			amip->thread_id, amip->thread_idptr, amip->file, amip->line);
		buf_len=strlen(buf);
		info_len=strlen(amip->info);
		if (128 - buf_len - 3 < info_len)
			{
			memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
			buf_len = 128 - 3;
			}
		else
			{
			BUF_strlcpy(buf + buf_len, amip->info,
				    sizeof buf - buf_len);
			buf_len = strlen(buf);
			}
		BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
		BIO_puts(l->bio,buf);
		amip = amip->next;
		}
	while(amip && amip->thread_id == ti && amip->thread_idptr == tip);
#ifdef LEVITTE_DEBUG_MEM
	if (amip)
		{
		fprintf(stderr, "Thread switch detected in backtrace!!!!\n");
		abort();
		}
#endif
	}
['static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)\n\t{\n\tchar buf[1024];\n\tchar *bufp = buf;\n\tAPP_INFO *amip;\n\tint ami_cnt;\n\tstruct tm *lcl = NULL;\n\tunsigned long ti;\n\tvoid *tip;\n#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))\n\tif(m->addr == (char *)l->bio)\n\t    return;\n\tif (options & V_CRYPTO_MDEBUG_TIME)\n\t\t{\n\t\tlcl = localtime(&m->time);\n\t\tBIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",\n\t\t\tlcl->tm_hour,lcl->tm_min,lcl->tm_sec);\n\t\tbufp += strlen(bufp);\n\t\t}\n\tBIO_snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",\n\t\tm->order,m->file,m->line);\n\tbufp += strlen(bufp);\n\tif (options & V_CRYPTO_MDEBUG_THREAD)\n\t\t{\n\t\tBIO_snprintf(bufp, BUF_REMAIN, "thread=%lu/%p, ", m->thread_id, m->thread_idptr);\n\t\tbufp += strlen(bufp);\n\t\t}\n\tBIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\\n",\n\t\tm->num,(unsigned long)m->addr);\n\tbufp += strlen(bufp);\n\tBIO_puts(l->bio,buf);\n\tl->chunks++;\n\tl->bytes+=m->num;\n\tamip=m->app_info;\n\tami_cnt=0;\n\tif (!amip)\n\t\treturn;\n\tti=amip->thread_id;\n\ttip=amip->thread_idptr;\n\tdo\n\t\t{\n\t\tint buf_len;\n\t\tint info_len;\n\t\tami_cnt++;\n\t\tmemset(buf,\'>\',ami_cnt);\n\t\tBIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,\n\t\t\t" thread=%lu/%p, file=%s, line=%d, info=\\"",\n\t\t\tamip->thread_id, amip->thread_idptr, amip->file, amip->line);\n\t\tbuf_len=strlen(buf);\n\t\tinfo_len=strlen(amip->info);\n\t\tif (128 - buf_len - 3 < info_len)\n\t\t\t{\n\t\t\tmemcpy(buf + buf_len, amip->info, 128 - buf_len - 3);\n\t\t\tbuf_len = 128 - 3;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tBUF_strlcpy(buf + buf_len, amip->info,\n\t\t\t\t    sizeof buf - buf_len);\n\t\t\tbuf_len = strlen(buf);\n\t\t\t}\n\t\tBIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\\"\\n");\n\t\tBIO_puts(l->bio,buf);\n\t\tamip = amip->next;\n\t\t}\n\twhile(amip && amip->thread_id == ti && amip->thread_idptr == tip);\n#ifdef LEVITTE_DEBUG_MEM\n\tif (amip)\n\t\t{\n\t\tfprintf(stderr, "Thread switch detected in backtrace!!!!\\n");\n\t\tabort();\n\t\t}\n#endif\n\t}']