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


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

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

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

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

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

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

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

crypto/asn1/a_utctm.c:298:2: 
296.   	if (year < 50)
297.   		year += 100;
298. > 	return_cmp(year,              tm->tm_year);
299.   	return_cmp(g2(s->data+2) - 1, tm->tm_mon);
300.   	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)
	{ 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)\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}"]