crypto/o_time.c:82: error: NULL_DEREFERENCE
  pointer `ts` last assigned on line 81 could be null and is dereferenced by call to `memcpy()` at line 82, column 2.
Showing all 4 steps of the trace


crypto/o_time.c:71:1: start of procedure OPENSSL_gmtime()
69.   #endif
70.   
71. > struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
72.   	{
73.   	struct tm *ts = NULL;

crypto/o_time.c:73:2: 
71.   struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
72.   	{
73. > 	struct tm *ts = NULL;
74.   
75.   #if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r))

crypto/o_time.c:81:2: 
79.   	ts = result;
80.   #elif !defined(OPENSSL_SYS_VMS)
81. > 	ts = gmtime(timer);
82.   	memcpy(result, ts, sizeof(struct tm));
83.   	ts = result;

crypto/o_time.c:82:2: 
80.   #elif !defined(OPENSSL_SYS_VMS)
81.   	ts = gmtime(timer);
82. > 	memcpy(result, ts, sizeof(struct tm));
83.   	ts = result;
84.   #endif

struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
	{
	struct tm *ts = NULL;
#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r))
	gmtime_r(timer,result);
	ts = result;
#elif !defined(OPENSSL_SYS_VMS)
	ts = gmtime(timer);
	memcpy(result, ts, sizeof(struct tm));
	ts = result;
#endif
#ifdef OPENSSL_SYS_VMS
	if (ts == NULL)
		{
		static $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL");
		static $DESCRIPTOR(lognam,"SYS$TIMEZONE_DIFFERENTIAL");
		char logvalue[256];
		unsigned int reslen = 0;
		struct {
			short buflen;
			short code;
			void *bufaddr;
			unsigned int *reslen;
		} itemlist[] = {
			{ 0, LNM$_STRING, 0, 0 },
			{ 0, 0, 0, 0 },
		};
		int status;
		time_t t;
		itemlist[0].buflen = sizeof(logvalue);
		itemlist[0].bufaddr = logvalue;
		itemlist[0].reslen = &reslen;
		status = sys$trnlnm(0, &tabnam, &lognam, 0, itemlist);
		if (!(status & 1))
			return NULL;
		logvalue[reslen] = '\0';
		status = atoi(logvalue);
		t = *timer - status;
#ifndef OPENSSL_THREADS
		ts=(struct tm *)localtime(&t);
#else
		{
		unsigned long unix_epoch[2] = { 1273708544, 8164711 };
		unsigned long deltatime[2];
		unsigned long systime[2];
		struct vms_vectime
			{
			short year, month, day, hour, minute, second,
				centi_second;
			} time_values;
		long operation;
		operation = LIB$K_DELTA_SECONDS;
		status = lib$cvt_to_internal_time(&operation,
			&t, deltatime);
		status = lib$add_times(unix_epoch, deltatime, systime);
		status = sys$numtim(&time_values, systime);
		result->tm_sec = time_values.second;
		result->tm_min = time_values.minute;
		result->tm_hour = time_values.hour;
		result->tm_mday = time_values.day;
		result->tm_mon = time_values.month - 1;
		result->tm_year = time_values.year - 1900;
		operation = LIB$K_DAY_OF_WEEK;
		status = lib$cvt_from_internal_time(&operation,
			&result->tm_wday, systime);
		result->tm_wday %= 7;
		operation = LIB$K_DAY_OF_YEAR;
		status = lib$cvt_from_internal_time(&operation,
			&result->tm_yday, systime);
		result->tm_yday--;
		result->tm_isdst = 0;
		ts = result;
#endif
		}
		}
#endif
	return ts;
	}
['struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)\n\t{\n\tstruct tm *ts = NULL;\n#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r))\n\tgmtime_r(timer,result);\n\tts = result;\n#elif !defined(OPENSSL_SYS_VMS)\n\tts = gmtime(timer);\n\tmemcpy(result, ts, sizeof(struct tm));\n\tts = result;\n#endif\n#ifdef OPENSSL_SYS_VMS\n\tif (ts == NULL)\n\t\t{\n\t\tstatic $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL");\n\t\tstatic $DESCRIPTOR(lognam,"SYS$TIMEZONE_DIFFERENTIAL");\n\t\tchar logvalue[256];\n\t\tunsigned int reslen = 0;\n\t\tstruct {\n\t\t\tshort buflen;\n\t\t\tshort code;\n\t\t\tvoid *bufaddr;\n\t\t\tunsigned int *reslen;\n\t\t} itemlist[] = {\n\t\t\t{ 0, LNM$_STRING, 0, 0 },\n\t\t\t{ 0, 0, 0, 0 },\n\t\t};\n\t\tint status;\n\t\ttime_t t;\n\t\titemlist[0].buflen = sizeof(logvalue);\n\t\titemlist[0].bufaddr = logvalue;\n\t\titemlist[0].reslen = &reslen;\n\t\tstatus = sys$trnlnm(0, &tabnam, &lognam, 0, itemlist);\n\t\tif (!(status & 1))\n\t\t\treturn NULL;\n\t\tlogvalue[reslen] = \'\\0\';\n\t\tstatus = atoi(logvalue);\n\t\tt = *timer - status;\n#ifndef OPENSSL_THREADS\n\t\tts=(struct tm *)localtime(&t);\n#else\n\t\t{\n\t\tunsigned long unix_epoch[2] = { 1273708544, 8164711 };\n\t\tunsigned long deltatime[2];\n\t\tunsigned long systime[2];\n\t\tstruct vms_vectime\n\t\t\t{\n\t\t\tshort year, month, day, hour, minute, second,\n\t\t\t\tcenti_second;\n\t\t\t} time_values;\n\t\tlong operation;\n\t\toperation = LIB$K_DELTA_SECONDS;\n\t\tstatus = lib$cvt_to_internal_time(&operation,\n\t\t\t&t, deltatime);\n\t\tstatus = lib$add_times(unix_epoch, deltatime, systime);\n\t\tstatus = sys$numtim(&time_values, systime);\n\t\tresult->tm_sec = time_values.second;\n\t\tresult->tm_min = time_values.minute;\n\t\tresult->tm_hour = time_values.hour;\n\t\tresult->tm_mday = time_values.day;\n\t\tresult->tm_mon = time_values.month - 1;\n\t\tresult->tm_year = time_values.year - 1900;\n\t\toperation = LIB$K_DAY_OF_WEEK;\n\t\tstatus = lib$cvt_from_internal_time(&operation,\n\t\t\t&result->tm_wday, systime);\n\t\tresult->tm_wday %= 7;\n\t\toperation = LIB$K_DAY_OF_YEAR;\n\t\tstatus = lib$cvt_from_internal_time(&operation,\n\t\t\t&result->tm_yday, systime);\n\t\tresult->tm_yday--;\n\t\tresult->tm_isdst = 0;\n\t\tts = result;\n#endif\n\t\t}\n\t\t}\n#endif\n\treturn ts;\n\t}']