# HG changeset patch # User Richard Laager # Date 1146534594 0 # Node ID f65e8d30ae53d02cb2bd4cd22e1700cf89e7e3b7 # Parent 4cf1db3ffada62fd32b58959069f424672e04c69 [gaim-migrate @ 16123] Fix a bug reported as SF Patch #1479875. "in gaim_icqinfo() in oscar.c , the struct tm used for filling in birthday date is not initialized, this cause crash in strftime on amd64 which is indirectly called by gaim_date_format_short. Reproduced on debian sarge amd64 stable." I chose a different solution than what was provided in the patch. committer: Tailor Script diff -r 4cf1db3ffada -r f65e8d30ae53 src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Tue May 02 01:44:14 2006 +0000 +++ b/src/protocols/oscar/oscar.c Tue May 02 01:49:54 2006 +0000 @@ -3650,12 +3650,22 @@ if (info->gender != 0) oscar_string_append(gc->account, str, "\n
", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) { - struct tm tm; - tm.tm_mday = (int)info->birthday; - tm.tm_mon = (int)info->birthmonth-1; - tm.tm_year = (int)info->birthyear-1900; + /* Initialize the struct properly or strftime() will crash + * on some systems (Debian Sarge AMD64). */ + time_t t = time(NULL); + struct tm *tm = localtime(&t); + + tm->tm_mday = (int)info->birthday; + tm->tm_mon = (int)info->birthmonth - 1; + tm->tm_year = (int)info->birthyear - 1900; + + /* To be 100% sure that the fields are re-normalized. + * If you're sure strftime() ALWAYS does this EVERYWHERE, + * feel free to remove it. --rlaager */ + mktime(tm); + oscar_string_append(gc->account, str, "\n
", _("Birthday"), - gaim_date_format_short(&tm)); + gaim_date_format_short(tm)); } if ((info->age > 0) && (info->age < 255)) { char age[5];