crypto/asn1/a_utctm.c:297: error: NULL_DEREFERENCE
  pointer `tm` last assigned on line 290 could be null and is dereferenced at line 297, column 2.
Showing all 8 steps of the trace


crypto/asn1/a_utctm.c:268:1: start of procedure ASN1_UTCTIME_cmp_time_t()
266.   
267.   
268. > int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
269.   	{
270.   	struct tm *tm;

crypto/asn1/a_utctm.c:276:6: Taking true branch
274.   #define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
275.   
276.   	if (s->data[12] == 'Z')
            ^
277.   		offset=0;
278.   	else

crypto/asn1/a_utctm.c:277:3: 
275.   
276.   	if (s->data[12] == 'Z')
277. > 		offset=0;
278.   	else
279.   		{

crypto/asn1/a_utctm.c:285:2: 
283.   		}
284.   
285. > 	t -= offset*60; /* FIXME: may overflow in extreme cases */
286.   
287.   #if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)

crypto/asn1/a_utctm.c:290:2: 
288.   	{ struct tm data; gmtime_r(&t, &data); tm = &data; }
289.   #else
290. > 	tm = gmtime(&t);
291.   #endif
292.   	

crypto/asn1/a_utctm.c:294:2: 
292.   	
293.   #define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
294. > 	year = g2(s->data);
295.   	if (year < 50)
296.   		year += 100;

crypto/asn1/a_utctm.c:295:6: Taking false branch
293.   #define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
294.   	year = g2(s->data);
295.   	if (year < 50)
            ^
296.   		year += 100;
297.   	return_cmp(year,              tm->tm_year);

crypto/asn1/a_utctm.c:297:2: 
295.   	if (year < 50)
296.   		year += 100;
297. > 	return_cmp(year,              tm->tm_year);
298.   	return_cmp(g2(s->data+2) - 1, tm->tm_mon);
299.   	return_cmp(g2(s->data+4),     tm->tm_mday);

int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
	{
	struct tm *tm;
	int offset;
	int year;
#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
	if (s->data[12] == 'Z')
		offset=0;
	else
		{
		offset = g2(s->data+13)*60+g2(s->data+15);
		if (s->data[12] == '-')
			offset = -offset;
		}
	t -= offset*60;
#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)
	{ struct tm data; gmtime_r(&t, &data); tm = &data; }
#else
	tm = gmtime(&t);
#endif
#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
	year = g2(s->data);
	if (year < 50)
		year += 100;
	return_cmp(year,              tm->tm_year);
	return_cmp(g2(s->data+2) - 1, tm->tm_mon);
	return_cmp(g2(s->data+4),     tm->tm_mday);
	return_cmp(g2(s->data+6),     tm->tm_hour);
	return_cmp(g2(s->data+8),     tm->tm_min);
	return_cmp(g2(s->data+10),    tm->tm_sec);
#undef g2
#undef return_cmp
	return 0;
	}
["int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)\n\t{\n\tstruct tm *tm;\n\tint offset;\n\tint year;\n#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')\n\tif (s->data[12] == 'Z')\n\t\toffset=0;\n\telse\n\t\t{\n\t\toffset = g2(s->data+13)*60+g2(s->data+15);\n\t\tif (s->data[12] == '-')\n\t\t\toffset = -offset;\n\t\t}\n\tt -= offset*60;\n#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)\n\t{ struct tm data; gmtime_r(&t, &data); tm = &data; }\n#else\n\ttm = gmtime(&t);\n#endif\n#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1\n\tyear = g2(s->data);\n\tif (year < 50)\n\t\tyear += 100;\n\treturn_cmp(year,              tm->tm_year);\n\treturn_cmp(g2(s->data+2) - 1, tm->tm_mon);\n\treturn_cmp(g2(s->data+4),     tm->tm_mday);\n\treturn_cmp(g2(s->data+6),     tm->tm_hour);\n\treturn_cmp(g2(s->data+8),     tm->tm_min);\n\treturn_cmp(g2(s->data+10),    tm->tm_sec);\n#undef g2\n#undef return_cmp\n\treturn 0;\n\t}"]