Mercurial > dwindows
comparison win/dw.c @ 757:d26bfc4cd1f0
Visual Studio 2008's runtime is crazy sensitive. I put in a bunch of parameter checks to make sure
nothing out of the ordinary ever ever gets passed to strftime().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 17 Mar 2011 16:42:53 +0000 |
parents | 67f2e890b9df |
children | 6d880e68e8d4 |
comparison
equal
deleted
inserted
replaced
756:ef17c8079f1d | 757:d26bfc4cd1f0 |
---|---|
7661 else if(flags[column] & DW_CFA_DATE) | 7661 else if(flags[column] & DW_CFA_DATE) |
7662 { | 7662 { |
7663 struct tm curtm; | 7663 struct tm curtm; |
7664 CDATE cdate = *((CDATE *)data); | 7664 CDATE cdate = *((CDATE *)data); |
7665 | 7665 |
7666 | 7666 memset(&curtm, 0, sizeof(struct tm)); |
7667 | |
7667 /* Safety check... zero dates are crashing | 7668 /* Safety check... zero dates are crashing |
7668 * Visual Studio 2008. -Brian | 7669 * Visual Studio 2008. -Brian |
7669 */ | 7670 */ |
7670 if(cdate.year > 1900) | 7671 if(cdate.year > 1900 && cdate.year < 2100) |
7671 { | 7672 { |
7672 curtm.tm_mday = cdate.day; | 7673 curtm.tm_mday = (cdate.day >= 0 && cdate.day < 32) ? cdate.day : 1; |
7673 curtm.tm_mon = cdate.month > 0 ? cdate.month - 1 : 0; | 7674 curtm.tm_mon = (cdate.month > 0 && cdate.month < 13) ? cdate.month - 1 : 0; |
7674 curtm.tm_year = cdate.year - 1900; | 7675 curtm.tm_year = cdate.year - 1900; |
7675 | 7676 |
7676 strftime(textbuffer, 100, "%x", &curtm); | 7677 strftime(textbuffer, 100, "%x", &curtm); |
7677 } | 7678 } |
7678 else | 7679 else |
7686 else if(flags[column] & DW_CFA_TIME) | 7687 else if(flags[column] & DW_CFA_TIME) |
7687 { | 7688 { |
7688 struct tm curtm; | 7689 struct tm curtm; |
7689 CTIME ctime = *((CTIME *)data); | 7690 CTIME ctime = *((CTIME *)data); |
7690 | 7691 |
7691 curtm.tm_hour = ctime.hours; | 7692 curtm.tm_hour = (ctime.hours >= 0 && ctime.hours < 24) ? ctime.hours : 0; |
7692 curtm.tm_min = ctime.minutes; | 7693 curtm.tm_min = (ctime.minutes >= 0 && ctime.minutes < 60) ? ctime.minutes : 0; |
7693 curtm.tm_sec = ctime.seconds; | 7694 curtm.tm_sec = (ctime.seconds >= 0 && ctime.seconds < 60) ? ctime.seconds : 0; |
7694 | 7695 |
7695 strftime(textbuffer, 100, "%X", &curtm); | 7696 strftime(textbuffer, 100, "%X", &curtm); |
7696 | 7697 |
7697 lvi.pszText = textbuffer; | 7698 lvi.pszText = textbuffer; |
7698 lvi.cchTextMax = strlen(textbuffer); | 7699 lvi.cchTextMax = strlen(textbuffer); |